【问题标题】:shell command does not work in excel 2010 vba in win 7shell命令在win 7中的excel 2010 vba中不起作用
【发布时间】:2014-01-31 20:22:00
【问题描述】:

最近使用 Adob​​e Acrobat 10 Standard 从 Win XP 升级到 Win 7。我需要正确的命令来使用 Excel 2010 VBA 打印 pdf 文件。正在使用以下有效的代码。

'acrobat executable
pdfApp="C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\AcroRd32.exe" 

'remote server file
f(doctyp)="\\sorl0008\groups\ACROBAT_DATA\PS\out\600374_e.pdf" 

'prints adobe pdf (ORIGINAL CODE THAT WORKED)
Shell pdfApp & " /t " & Chr(34) & f(doctyp) & Chr(34), vbNormalFocus 

当我现在运行它时,一旦执行了 shell 命令,屏幕就会短暂闪烁,并且绝对没有任何反应。为什么会这样?它与 Adob​​e Acrobat 10 有关吗?我可以使用以下代码成功打开文件,但大多数时候我不想查看文件,只需发送到默认打印机并继续。 v = Shell(pdfApp, vbNormalFocus) '打开 adobe ActiveWorkbook.FollowHyperlink f(doctyp) '在 adobe 中打开文件

即使我打开文件然后尝试打印,我也会得到与快速屏幕闪烁相同的结果,但什么也没有。我在 Windows 7 中关闭了数据执行保护,但它仍然不起作用。有什么想法吗?

【问题讨论】:

  • Even if I open the file and then try to print I get the same result of a quick screen flash and nothing. 你的意思是手动打开文件后?如果是,那么您的打印机设置可能有问题?

标签: excel shell vba pdf acrobat


【解决方案1】:

您的代码在 64 位 Win 7 上为我工作,除了 Adob​​e 阅读器的路径不同:

'acrobat executable
'pdfApp = "C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\AcroRd32.exe"
pdfApp = "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"

'remote server file
'f(doctyp) = "\\sorl0008\groups\ACROBAT_DATA\PS\out\600374_e.pdf"
doc = "some unc path"

'prints adobe pdf (ORIGINAL CODE THAT WORKED)
Shell pdfApp & " /t " & Chr(34) & doc & Chr(34), vbNormalFocus

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-25
    • 2014-12-13
    • 2015-11-10
    • 2012-07-25
    • 2013-08-07
    • 1970-01-01
    • 1970-01-01
    • 2012-02-19
    相关资源
    最近更新 更多