是否可以不使用"Shell32.dll“一词来编写文件打印例程,因为在XLSB文件中的受保护VBA中使用此命令会标记Excel文件包含与特洛伊木马程序相关的脚本,并且无法通过电子邮件发送或下载excel文件。
导致特洛伊木马程序错误消息的现有代码。
Option Explicit
#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
Public Const SW_HIDE = 0
Sub PrintFile(ByVal strFilePath As String)
Dim retVal As Long
retVal = ShellExecute(0, "Print", strFilePath, 0, 0, SW_HIDE)
If retVal < 32 Then
MsgBox "An error occured...Could not print"
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End If
End Sub发布于 2017-04-26 03:26:31
在VBA.Interaction模块中,VBA标准库对API函数包含了一个很薄包装器,命名为Shell很方便-也许这对您有用?
result = Shell("print " & path, vbHide)https://stackoverflow.com/questions/43618711
复制相似问题