exporting to excel template (1 Viewer)

bigmac

Registered User.
Local time
Today, 13:32
Joined
Oct 5, 2008
Messages
295
hi all, is it possible to create an excel template and use it when exporting a table using the external data, export to excel option? if so how?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:32
Joined
May 7, 2009
Messages
19,230
you will need Automation to do that.
open the "formatted" workbook.
open the recordset from table
workbook.range("A1").copyfromrecordset theRecordset.
 

Chief

Registered User.
Local time
Today, 13:32
Joined
Feb 22, 2012
Messages
156
you will need Automation to do that.
open the "formatted" workbook.
open the recordset from table
workbook.range("A1").copyfromrecordset theRecordset.
G'Day arnelgp,

Am I able to ask you to elaborate on this for me please?
This is my current code that just exports straight out into excel. (On vbYes)
But I want to advance on this to open in an excel template where I will have formulas to calculate imported data. (If Possible)

Code:
Private Sub BtnOps_SchedAss_Click()
Dim iExport As String
iExport = ""
    iExport = MsgBox("Do you want to Export to Excel?" & vbCrLf & "Export Options ", vbYesNo + vbExclamation + vbApplicationModal + vbDefaultButton1, "Export")
   
    Select Case iExport
        Case vbYes: ' Export Data to Excel File
            DoCmd.OutputTo acOutputQuery, "Ops_AssSchedFCastQ", acFormatXLSX, , True
        Case vbNo: ' View as Datasheet
            DoCmd.OpenQuery "Ops_AssSchedFCastQ", acViewNormal
    End Select
End Sub

Excel:
1639534925198.png


I will be putting more formulas in but this is an example.
Hopefully you can help. :)
Thanks Mate

EDIT: Would it be better to export the date into a workbook, into its own work sheet, then have another worksheet already drawing from the data? hmmm
 

Attachments

  • Ops_AssSchedFCastQ.zip
    8.7 KB · Views: 196

Isaac

Lifelong Learner
Local time
Today, 13:32
Joined
Mar 14, 2017
Messages
8,777
I prefer CopyFromRecordset, as the built-in Access commands (OutputTo, TransferSpreadsheet), have caused me trouble either in Access front ends with tables and nav pane hidden as well as cutting off long text. CopyFromRecordset seems to have the least overall problems
 

Chief

Registered User.
Local time
Today, 13:32
Joined
Feb 22, 2012
Messages
156
you will need Automation to do that.
open the "formatted" workbook.
open the recordset from table
workbook.range("A1").copyfromrecordset theRecordset.
Here is a sample DB
I have also included the excel template workbook.

I think It would be good to bring in the data on worksheet Ops_AssSchedFCastQ, deleting old data and replacing with new.
Then The Results sheet stays in place and calculates off the Data sheet.

What do you think?

1639624233807.png
 

Attachments

  • Ops_AssSchedFCastQ.zip
    13 KB · Views: 175
  • Sample_Export.zip
    69.9 KB · Views: 192

Users who are viewing this thread

Top Bottom