替代使用shell32.dll

时间:2017-04-25 18:50:14

标签: vba printing trojan

文件打印例程是否可以不使用“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

1 个答案:

答案 0 :(得分:0)

VBA标准库在output {1, 2, 3, 4, 5} {6, 7} {9, 11, 12} {10} 模块中包含围绕该API函数的瘦包装器,方便地命名为Shell - 这可能对您有用吗?

VBA.Interaction