我在运行32位Microsoft Office的64位计算机(Windows 7)上构建了一个应用程序。客户端机器是64位Windows和64位办公室。从32位到64位的VBA代码 - Ms Access
我最初有comdlg32.dll问题,但包含PtrSafe关键字。接下来的问题是我安装到客户端机器中的IPCONFIG.dll丢失。
我现在编译好了,但我试图使用文件保存对话框(由肯Getz代码)。它似乎在跳过打开实际对话框并直接运行到运行时错误2522(需要文件名)。任何帮助赞赏。这是我使用的代码(回指向肯·盖茨的功能):
Function exportData_Click()
Dim strFilter As String
Dim strSaveFileName As String
Dim The_Year As Variant
Dim ctlCurrentControl As Control
Dim queryName As String
'Get the name of the control button clicked (corresponds to query name to be run)
Set ctlCurrentControl = Screen.ActiveControl
queryName = ctlCurrentControl.Name
'Get combobox value and assign relavent values to The_Year
The_Year = Forms![Extract Data]!Extract_Year.value
'Change the year from a variant to what we need in the SQL
If The_Year Like "20*" Then
The_Year = CInt(The_Year)
'MsgBox The_Year & "Data Type = " & VarType(The_Year)
Else: The_Year = "*"
'MsgBox The_Year & "Data Type = " & VarType(The_Year)
End If
'Set queryYear variable
setYear (The_Year)
'Check the variable is correct
'MsgBox getYear()
'Open the Save as Dialog to choose location of query save
strFilter = ahtAddFilterItem("Excel Files (*.xlsx)", "*.xlsx")
strSaveFileName = ahtCommonFileOpenSave(_
openFile:=False, _
Filter:=strFilter, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, queryName, strSaveFileName
End Function
调试点,这条线:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, queryName, strSaveFileName
感谢remou。它不会用Return =语句进行编译。我已经评论过,对话框正在出现。但是,saveAs仍然没有保存任何内容。 –
全部排序。我只是用一个字符串(strSaveFileName)= f.SelectedItems(1) 非常感谢remou! –