Export not working (1 Viewer)

Locopete99

Registered User.
Local time
Today, 09:59
Joined
Jul 11, 2016
Messages
163
Hi Guys,

Can someone take a look at the below?

I cant seem to get the export to work.

It works as far as creating the directory and then stops. No error message or any issues but also there is no exported excel file in the folder!

Code:
DirName = "B:\" & fOSUserName & "\Register Report\Outdebt\"
strpath = DirName & "outdebt.xlsx"
If Dir(DirName, vbDirectory) = "" Then
MkDir DirName
Else
End If

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "Qry_debtout", strpath, True
 

vba_php

Forum Troll
Local time
Today, 11:59
Joined
Oct 6, 2019
Messages
2,884
hmmmm...interesting. what version of access are you using? i'm running 2016 with office 365. I tried running your code and I got the error in the attached image when trying to open the excel file that was produced. your code produced the file but it was either invalid or corrupted. I exported a query object just like you are doing. I also tried to run the export op by exporting xlsx types "acSpreadsheetTypeExcel9", "acSpreadsheetTypeExcel8" and "acSpreadsheetTypeExcel7" and got the same error as well.

not sure what to tell you. perhaps someone else has researched this? you might try googling the result in the attached image...?
 

Attachments

  • not valid format.png
    not valid format.png
    6.1 KB · Views: 119

isladogs

MVP / VIP
Local time
Today, 16:59
Joined
Jan 14, 2017
Messages
18,186
Two things
1. Debug.Print strPath
2. Try acSpreadsheetTypeExcel12xml which is intended for xlsx files
 

Users who are viewing this thread

Top Bottom