我曾经使用此代码在Windows 7 32位上打印出MS Access 2010 32位的PDF文件。
#If VBA7 Then
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) _
As Long
#Else
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) _
As Long
#End If
现在,我们更改为Windows 7 64位,但运行此功能时Office 32位和所有Office应用程序仍然崩溃。
奇怪,因为如果我使用"打开"异。 "打印"它按预期工作!
请帮助,因为我失去了如何纠正我的功能再次运行。
我想要的只是从Access打印出PDF文件而不打开文件。 由于连续存在多个文件,我无法打开任何PDF应用程序来打印文件。
由于 迈克尔
编辑:经过长时间的搜索,我找到了解决方案!
您必须在64位应用程序中声明该函数,但要使shure在32位声明两者的机器上运行它。
promoted object
答案 0 :(得分:0)
因此,为了表明这一点,并保证这确实解决了我的相同情况。如果您在线引用Windows DLL,则需要确保根据正在使用访问数据库的环境(32位对64位)使用正确的DLL,您可以如上所述动态执行此操作(并在此处重复) )
#If VBA7 Then
Private Declare PtrSafe Function apiShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long _
) As Long
#Else
Private Declare Function apiShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long _
) As Long
#End If