|
楼主 |
发表于 2022-8-25 12:09
|
显示全部楼层
这代码违规吗,发不出来?
Sub test()
Dim thispath, myfile, a$, Savetime As Single, mydoc As Document
thispath = ActiveDocument.path & "\"
myfile = Dir(thispath & "*.pdf")
Do While myfile <> ""
If myfile <> ActiveDocument.Name Then
'Shell "C:\Program Files (x86)\Foxit Software\Foxit PhantomPDF\FoxitPhantomPDF.exe " & thispath & myfile
ReturnValue = Shell("C:\Program Files (x86)\Foxit Software\Foxit PhantomPDF\FoxitPhantomPDF.exe " & thispath & myfile, 1)
Savetime = Timer
While Timer < Savetime + 20'等待福昕软件完全加载,不然捕捉不到
DoEvents
Wend
AppActivate ReturnValue
'SendKeys "+{TAB}{RIGHT}{RIGHT}{ENTER}{TAB}%{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}{ENTER}", True
SendKeys "%", True
SendKeys "%", True'两次Alt按键是为了激活当前打开的PDF文档,不添加整个程序没反应
'SendKeys "%F", True
'SendKeys "%A", True
'SendKeys "+{TAB}", True
SendKeys "%", True
SendKeys "7", True'Alt+7是另存为的快捷键
SendKeys "{RIGHT}{RIGHT}{ENTER}", True
SendKeys "{TAB}", True
SendKeys "%{DOWN}", True
SendKeys "{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}", True
SendKeys "{ENTER}{ENTER}", True
End If
Savetime = Timer
While Timer < Savetime + 40'PDF转换word文档过程等待
DoEvents
Wend
Set mydoc = ActiveDocument
mydoc.Close
Shell "cmd.exe /c taskkill /im FoxitPhantomPDF.exe /f"'关闭福昕软件,不然下一个循环会出错
Savetime = Timer
While Timer < Savetime + 3
DoEvents
Wend
myfile = Dir
Loop
End Sub |
|