2014-02-20 41 views
0
strTarget = "C:\My Name\K.jpg" 

正如您所見,存儲在strTarget中的地址中有一個空格,現在我試圖將它傳遞給應用程序,但它不起作用因爲在地址:(將空格作爲cmd參數傳遞給程序

TargetApp.Run """C:\My App\here.exe"" " & strTarget ,,true 

空間,如果我改變strTarget到「C:\ MYNAME \ K.jpg」不具有空間,將工作

如何解決這個問題

回答

2

你需要添加雙引號aro UND圖像路徑你周圍的可執行文件路徑一樣的工作方式:

TargetApp.Run """C:\My App\here.exe"" """ & strTarget & """" ,,true 

我通常建議使用此一功能,報價,因爲它顯著增加了可讀性:

Function qq(str) : qq = Chr(34) & str & Chr(34) : End Function 

app = "C:\My App\here.exe" 
img = "C:\My Name\K.jpg" 

TargetApp.Run qq(app) & " " & qq(img), 0, True