简体   繁体   English

我想使用 VBScript 打开具有特定应用程序的文件

[英]I want to open a file with a specific application using VBScript

I am trying to download some bank statements which only come in.pdf format and convert them to an excel file.我正在尝试下载一些仅输入的银行对帐单。pdf 格式并将它们转换为 excel 文件。 I use NitroPDF.exe to convert the.pdf file to an excel file and then have created a VBA script to clean it up and append it into my main Excel file. I use NitroPDF.exe to convert the.pdf file to an excel file and then have created a VBA script to clean it up and append it into my main Excel file. I have to do the conversion manually up to the point where Excel VBA takes over.我必须手动进行转换,直到 Excel VBA 接管为止。 I would like to automate it, not sure how.我想自动化它,不知道如何。 I have tried to use cmd line:我曾尝试使用 cmd 线:

"C:\Program Files\Nitro\Pro\12\NitroPDF.exe" "C:\Users\Adam\OneDrive\Desktop\TEMP\WebBroker - Balances.pdf

And that works fine in that it opens NitroPDF with the file I need in it.这很好用,因为它会打开 NitroPDF,其中包含我需要的文件。 however when I try to run it in a.vbs file (named: RunningPdf.vbs) like this:但是,当我尝试在一个.vbs 文件(名为:RunningPdf.vbs)中运行它时,如下所示:

    Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "C:\Program Files\Nitro\Pro\12\NitroPDF.exe" "C:\Users\Adam\OneDrive\Desktop\TEMP\WebBroker - Balances.pdf", 1, true

I get an error:我收到一个错误:

Script:  C:\Users\Adam\OneDrive\Desktop\TEMP\RunningPdf.vbs  
Line: 2
Char: 59  
Error: Expected end of statement  
Code: 800A0401  
Source: Microsoft VBScript compilation error

What am I doing wrong in my translation from cmd to vbs?我在从 cmd 到 vbs 的翻译中做错了什么? Should I even be using vbs for this?我什至应该为此使用vbs吗? how could I meld this code to my Excel VBA code?我怎样才能将此代码融合到我的 Excel VBA 代码中? I was planning to use sedkeys in the vbs code once NitroPDF opened, to automate the conversion from pdf to Excel, is this the best way?我打算在 NitroPDF 打开后在 vbs 代码中使用 sedkeys,以自动将 pdf 转换为 Excel,这是最好的方法吗? Sorry for the lengthy post, any help would be greatly appreciated Thank you抱歉,帖子冗长,任何帮助将不胜感激谢谢

Always worth quoting file paths, but then you need to escape those quotes in the value being passed to Shell总是值得引用文件路径,但是您需要在传递给Shell的值中转义这些引号

WshShell.Run """C:\Program Files\Nitro\Pro\12\NitroPDF.exe"" ""C:\Users\Adam\OneDrive\Desktop\TEMP\WebBroker - Balances.pdf""", 1, true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM