Ms access 从32位到64位的VBA代码-Ms访问

Ms access 从32位到64位的VBA代码-Ms访问,ms-access,vba,ms-access-2010,32bit-64bit,Ms Access,Vba,Ms Access 2010,32bit 64bit,我已经在运行32位Microsoft Office的64位计算机(windows 7)上构建了一个应用程序。客户端计算机是64位windows和64位office 我最初在comdlg32.dll上有问题,但包含了PtrSafe关键字。下一个问题是我安装到客户机中的IPCONFIG.dll丢失 我现在已经可以编译了,但我正在尝试使用文件保存对话框(代码由Ken Getz编写)。它似乎跳过了打开实际对话框的过程,直接运行到运行时错误2522(需要文件名)。谢谢你的帮助。这是我正在使用的代码(引用K

我已经在运行32位Microsoft Office的64位计算机(windows 7)上构建了一个应用程序。客户端计算机是64位windows和64位office

我最初在comdlg32.dll上有问题,但包含了PtrSafe关键字。下一个问题是我安装到客户机中的IPCONFIG.dll丢失

我现在已经可以编译了,但我正在尝试使用文件保存对话框(代码由Ken Getz编写)。它似乎跳过了打开实际对话框的过程,直接运行到运行时错误2522(需要文件名)。谢谢你的帮助。这是我正在使用的代码(引用Ken Getz的函数):

调试指向此行:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, queryName, strSaveFileName

我发现此代码将与MS Access 64一起使用:

Function GetFile(strStartIn As String, strFilter As String) As String
Dim f As Object

   Set f = Application.FileDialog(3)
   f.AllowMultiSelect = False
   f.InitialFileName = strStartIn & strFilter
   f.Show

   GetFile = f.SelectedItems(1)
End Function
它不像Ken Getz的代码那样简洁,但应该适合选择要保存或打开的文件。您可以引用Microsoft Office库以使用内置常量,例如:

msoFileDialogOpen (1) 
msoFileDialogSaveAs (2)
msoFileDialogFilePicker (3) 
msoFileDialogFolderPicker (4) 

()

我发现此代码将与MS Access 64一起使用:

Function GetFile(strStartIn As String, strFilter As String) As String
Dim f As Object

   Set f = Application.FileDialog(3)
   f.AllowMultiSelect = False
   f.InitialFileName = strStartIn & strFilter
   f.Show

   GetFile = f.SelectedItems(1)
End Function
它不像Ken Getz的代码那样简洁,但应该适合选择要保存或打开的文件。您可以引用Microsoft Office库以使用内置常量,例如:

msoFileDialogOpen (1) 
msoFileDialogSaveAs (2)
msoFileDialogFilePicker (3) 
msoFileDialogFolderPicker (4) 

()

对于我的应用程序,另一种行之有效的方法是检查VBA的版本:

#if Vba7 then 
'  Code is running in the new VBA7 editor 
     #if Win64 then 
     '  Code is running in 64-bit version of Microsoft Office 
     #else 
     '  Code is running in 32-bit version of Microsoft Office 
     #end if 
#else 
' Code is running in VBA version 6 or earlier 
#end if 

#If Vba7 Then 
Declare PtrSafe Sub... 
#Else 
Declare Sub... 
#EndIf 

对于我的应用程序,另一种行之有效的方法是检查VBA的版本:

#if Vba7 then 
'  Code is running in the new VBA7 editor 
     #if Win64 then 
     '  Code is running in 64-bit version of Microsoft Office 
     #else 
     '  Code is running in 32-bit version of Microsoft Office 
     #end if 
#else 
' Code is running in VBA version 6 or earlier 
#end if 

#If Vba7 Then 
Declare PtrSafe Sub... 
#Else 
Declare Sub... 
#EndIf 

谢谢你。它不会使用Return=语句编译。我已经把它注释掉了,对话框就出现了。但是,saveAs仍然没有保存任何内容。全部已排序。我刚刚用了一个字符串(strSaveFileName)=f.SelectedItems(1)非常感谢!谢谢你。它不会使用Return=语句编译。我已经把它注释掉了,对话框就出现了。但是,saveAs仍然没有保存任何内容。全部已排序。我刚刚用了一个字符串(strSaveFileName)=f.SelectedItems(1)非常感谢!