将Ms Access表导出到Excel

时间:2014-12-26 09:55:19

标签: excel vba

我使用此代码,但它显示“编译错误:预期结束子” 对不起我对此不好。但愿意学习。

Private Sub Command125_Click()
Public Function TransferToExcel()

On Error GoTo ErrorHandler


Dim strTable As String
Dim strWorkSheetPath As String

strWorkSheetPath = "C:\Users\Desktop\"
strWorkSheetPath = strWorkSheetPath & "APK.xlsx"
strTable = "tblRegistration"

DoCmd.TransferSpreadsheet transfertype:=acExport, _
spredsheettype:=acSpreadsheetTypeExcel12Xml, _
TableNmae:=strTable, FileName:=strWorkSheetPath, _
hasfieldnames:=True

ErrorHandlerExit:
Exit Function

ErrorHandler:
MsgBox "Error No: " & Err.Number _
& "; Description: " & Err.Description
Resume ErrorHandlerExit

End Function
End Sub

0 个答案:

没有答案