簡體   English   中英

我想使用 VBScript 打開具有特定應用程序的文件

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

我正在嘗試下載一些僅輸入的銀行對帳單。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. 我必須手動進行轉換,直到 Excel VBA 接管為止。 我想自動化它,不知道如何。 我曾嘗試使用 cmd 線:

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

這很好用,因為它會打開 NitroPDF,其中包含我需要的文件。 但是,當我嘗試在一個.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

我收到一個錯誤:

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

我在從 cmd 到 vbs 的翻譯中做錯了什么? 我什至應該為此使用vbs嗎? 我怎樣才能將此代碼融合到我的 Excel VBA 代碼中? 我打算在 NitroPDF 打開后在 vbs 代碼中使用 sedkeys,以自動將 pdf 轉換為 Excel,這是最好的方法嗎? 抱歉,帖子冗長,任何幫助將不勝感激謝謝

總是值得引用文件路徑,但是您需要在傳遞給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