|
楼主 |
发表于 2024-9-26 11:04
|
显示全部楼层
Function test()
On Error GoTo AcroExch_App_MenuItemExecute_SKIP
'Acrobatオブジェクトの定義&作成
'Acrobat 4,5,6 の時
' Dim objAcroApp As Acrobat.CAcroApp
' Dim objAcroPDDoc As Acrobat.CAcroPDDoc
' Dim objAcroAVDoc As Acrobat.CAcroAVDoc
'
' Set objAcroApp = CreateObject("AcroExch.App")
' Set objAcroPDDoc = CreateObject("AcroExch.PDDoc")
' Set objAcroAVDoc = CreateObject("AcroExch.AVDoc")
'Acrobat 7,8,9,10,11 の時
Dim objAcroApp As New Acrobat.AcroApp
Dim objAcroPDDoc As New Acrobat.AcroPDDoc
Dim objAcroAVDoc As New Acrobat.AcroAVDoc
'以降はAcrobat全て共通
Dim lRet As Long '戻り値
Const CON_PDF_FILE = "C:\Users\Administrator\Desktop\1.pdf"
查找值 = "2023"
替换值 = "2028"
lRet = objAcroApp.Show
lRet = objAcroPDDoc.Open(CON_PDF_FILE)
objAcroPDDoc.OpenAVDoc CON_PDF_FILE
lRet = objAcroApp.MenuItemIsEnabled("Find")
If lRet = True Then
lRet = objAcroApp.MenuItemExecute("Find")
End If
Application.Wait Now + TimeValue("00:00:01")
'
SendKeys 查找值, True
Application.Wait Now + TimeValue("00:00:01")
SendKeys "+{TAB}", True
Application.Wait Now + TimeValue("00:00:01")
SendKeys "+{TAB}", True
Application.Wait Now + TimeValue("00:00:01")
SendKeys "{Enter}", True
Application.Wait Now + TimeValue("00:00:01")
lRet = objAcroApp.MenuItemIsEnabled("Find")
If lRet = True Then
lRet = objAcroApp.MenuItemExecute("Find")
End If
Application.Wait Now + TimeValue("00:00:01")
SendKeys "+{TAB}", True
Application.Wait Now + TimeValue("00:00:01")
SendKeys "+{TAB}", True
Application.Wait Now + TimeValue("00:00:01")
SendKeys "{Enter}", True
Application.Wait Now + TimeValue("00:00:01")
SendKeys 替换值, True
Application.Wait Now + TimeValue("00:00:01")
SendKeys "{TAB}", True
Application.Wait Now + TimeValue("00:00:01")
For i = 1 To 10 '替换次数
SendKeys "{Enter}", True
Application.Wait Now + TimeValue("00:00:01")
Next
objAcroPDDoc.Save 1, CON_PDF_FILE
objAcroPDDoc.Close
lRet = objAcroApp.CloseAllDocs
lRet = objAcroApp.Hide
lRet = objAcroApp.Exit
AcroExch_App_MenuItemExecute_SKIP:
Set objAcroAVDoc = Nothing
Set objAcroPDDoc = Nothing
Set objAcroApp = Nothing
End Function
|
|