1. 程式人生 > >VBA調用DOS程序兩種方法

VBA調用DOS程序兩種方法

cnblogs fstream scrip 窗體 pre obj 程序 .exe style

    Set wsh = VBA.CreateObject("WScript.Shell")
    wsh.Run strExePath & " g", vbHide, True
    Set wshOut = wsh.exec(strExePath & " g").StdOut
    
    While Not wshOut.AtEndOfStream
        sLine = wshOut.ReadLine
        Debug.Print sLine
    Wend

run可以隱藏窗體

exec可以獲取dos打印輸出值

貌似沒有即能隱藏窗體又能獲取打印結果的辦法。

VBA調用DOS程序兩種方法