首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用shell32.dll的替代方案

使用shell32.dll的替代方案
EN

Stack Overflow用户
提问于 2017-04-26 02:50:14
回答 1查看 521关注 0票数 0

是否可以不使用"Shell32.dll“一词来编写文件打印例程,因为在XLSB文件中的受保护VBA中使用此命令会标记Excel文件包含与特洛伊木马程序相关的脚本,并且无法通过电子邮件发送或下载excel文件。

导致特洛伊木马程序错误消息的现有代码。

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2017-04-26 03:26:31

VBA.Interaction模块中,VBA标准库对API函数包含了一个很薄包装器,命名为Shell很方便-也许这对您有用?

代码语言:javascript
复制
result = Shell("print " & path, vbHide)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43618711

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档