2016-12-23 68 views
2

我需要在特殊程序中打開一個文件。例如,我需要打開* .docx文件,如果辦公室字。如何使用autoit在特殊程序中打開文件?

我已經找到了如何運行Office

Example() 

Func Example() 
    ; Run Notepad with the window maximized. 
    Local $iPID = Run("C:\Program Files (x86)\Microsoft Office\Office15\WINWORD.EXE", "", @SW_SHOWMAXIMIZED) 

    ; Wait 10 seconds for the Notepad window to appear. 
    WinWait("[CLASS:winword]", "", 5) 

    ; Wait for 2 seconds. 
    Sleep(2000) 

    ; Close the Notepad process using the PID returned by Run. 
    ProcessClose($iPID) 
EndFunc ;==> 

如何打開文件?

回答

1

Word文檔,你只需要把這個文件的名稱作爲命令行參數

Example() 

Func Example() 
    ; Run Notepad with the window maximized. 
    Local $iPID = Run("C:\Program Files (x86)\Microsoft Office\Office15\WINWORD.EXE" & " " & "path_to_document", "", @SW_SHOWMAXIMIZED) 

    ; Wait 10 seconds for the Notepad window to appear. 
    WinWait("[CLASS:winword]", "", 5) 

    ; Wait for 2 seconds. 
    Sleep(2000) 

    ; Close the Notepad process using the PID returned by Run. 
    ProcessClose($iPID) 
EndFunc ;==> 

或者使用的ShellExecute()

相關問題