Unreliable Results from Export

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
The below Access Code I am stepping thru (Using F8); as soon as I complete the Last shown Line -- DoCmd.TransferSpreadsheet....
I open my Excel, then the file LastExport.xlsx and it is Not Updating

If I run qryDataExportedToExcel and compare content to my LastExport.xlsx
they are NOT the same; What could be happening?

TIA,

Jim


Code:
Sub ExportToMyExcel()
    Dim appExcel As Object
    Dim mySourceBook As Object
    Dim myDestinationBook As Object
    Dim mySourceSheet As Object
    Dim myDestinationSheet As Object
    Dim Rng1 As Object
    Dim Rng2 As Object
    Dim LR As Long

    On Error Resume Next

    Set appExcel = GetObject(, "Excel.Application")
    
    If Err.Number = 429 Then
    Set appExcel = CreateObject("Excel.Application")
    End If
    
    On Error GoTo 0
    
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qryDataExportedToExcel", _
                              "C:\Users\James\Documents\Trusted_Locations\CBF\LastExport.xlsx", True
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
HALT !!!!

Further Searching (Google) revealed that "acSpreadsheetTypeExcel12" - as I had
needs to have "Xml" tacked/added on as follows:

acSpreadsheetTypeExcel12Xml

Everything works fine NOW;

Jim
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top