DannyDont

New Member
Joined
Mar 7, 2014
Messages
40
I currently export a query to an Excel File and then process it further with VBA.
I am not sure why, but for some reason Excel does not like the format of the file.
I am attempting to export as a XLSX file but can't seem to find any help on the internet that is specific enough to help me.
I currently make the Export in an Access Macro in an MDB Access DB.
I have now converted it to ACCDB and attempted to use the ExportWithFormat in the Macro without success.
So I went further to see what could be done with VBA in Access and came across the Transfer Spreadsheet DoCmd.
Here is the line that I created, that does not work.
[
DoCmd.TransferSpreadsheet(acExport, acSpreadsheetTYpeExcel12Xml, qryAddressPull-Step3-PrtPub, C:PCP\GMLSRC\EXCEL_REPORT_STUFF\Export-PrtPubList.xlsx)
]
-or-
[
DoCmd.TransferSpreadsheet(1, 10, qryAddressPull-Step3-PrtPub, C:PCP\GMLSRC\EXCEL_REPORT_STUFF\Export-PrtPubList.xlsx)
]

- or with quotes -

[
DoCmd.TransferSpreadsheet(acExport, acSpreadsheetTYpeExcel12Xml, "qryAddressPull-Step3-PrtPub", "C:PCP\GMLSRC\EXCEL_REPORT_STUFF\Export-PrtPubList.xlsx")
]
-or-
[
DoCmd.TransferSpreadsheet(1, 10, "qryAddressPull-Step3-PrtPub", "C:PCP\GMLSRC\EXCEL_REPORT_STUFF\Export-PrtPubList.xlsx")
]

Any help would be greatly appreciated.
Thank you,
Dan Foltz
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I did finally get the VBA Code to work. I believe that my File Path was incorrect.
Sorry for the interruption.
 
Upvote 0
Solution
Here is the working subroutine.
Private Sub Command28_Click()
Call DoCmd.TransferSpreadsheet(acExport, acSpreadsheetTypeExcel12Xml, "qryAddressPull-Step3-PrtPub", "C:\PCP\GMLSRC\Export-PrtPubList.xlsx")

End Sub
 
Upvote 0
I saw right away that you missed the \ after C:
Maybe next time, open File Explorer, navigate to the folder containing the file and copy the path from the address bar. You'd have to tack on the \FileName.xlsx by either typing, or once you paste the path to the folder, right click the file, choose properties and copy the file name.
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,975
Members
449,095
Latest member
Mr Hughes

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