简体   繁体   English

将访问表导出到Excel错误

[英]Exporting Access Tables to Excel Error

I am trying to export my access tables to excel but keep getting the "Error, Expected Identifier" when I input my query and path name. 我试图将我的访问表导出到excel,但是当我输入查询和路径名时,总是得到“错误,期望的标识符”。 Below is the code: 下面是代码:

Sub exportToXl()

On Error GoTo ErrorHandler

Dim dbTable As String

Sub dmwExport("SuperDash_Usage_Rpt", "L:\WF Reporting\Superdash\SuperdashRpt.xlsx")

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

DoCmd.TransferSpreadsheet _

TransferType:=acExport, _

SpreadsheetType:=acSpreadsheetTypeExcel12Xml, _

TableName:="SuperDash_Usage_Rpt", _

FileName:=L:\WF Reporting\Superdash\SuperdashRpt.xlsx, _

HasFieldNames:=True

End Sub

This is the exact queryname from my access table and the path that I want to exported table to go to. 这是我的访问表中的确切查询名,也是我要导出表去的路径。 What I am doing wrong? 我做错了什么?

Sub dmwExport更改为Call dmwExport

You may want to add " " around your file path in order for it to read it as text rather than a variable. 您可能需要在文件路径周围添加" " ,以使其以文本而非变量的形式读取。

Like so: 像这样:

Sub exportToXl()

On Error GoTo ErrorHandler

Dim dbTable As String

Sub dmwExport("SuperDash_Usage_Rpt", "L:\WF Reporting\Superdash\SuperdashRpt.xlsx")

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

DoCmd.TransferSpreadsheet _

TransferType:=acExport, _

SpreadsheetType:=acSpreadsheetTypeExcel12Xml, _

TableName:="SuperDash_Usage_Rpt", _

'Added "" around file path in order to be read as text
FileName:="L:\WF Reporting\Superdash\SuperdashRpt.xlsx", _

HasFieldNames:=True

End Sub

You may also be able to "short-hand" the DoCmd.TransferSpreadSheet . 您还可以“ DoCmd.TransferSpreadSheetDoCmd.TransferSpreadSheet

Example: 例:

DoCmd.TransferSpreadSheet acExport, acSpreadSheetTypeExcel12Xml, "SuperDash_Usage_Rpt", "L:\WF Reporting\Superdash\SuperdashRpt.xlsx", True

I hope this helps! 我希望这有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM