我需要在特殊程序中打开一个文件。例如,我需要打开* .docx文件,如果办公室字。
我已经想出了如何办公室
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 ;==>
如何打开文件?
答案 0 :(得分: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()