因此,我希望自动为PDF添加书签。我成功执行了前几个循环,但之后又出现了故障,并且没有将正确的位置添加为书签。同样,我想知道^ f和^ b是否有更好的替代方法。这是我到目前为止的代码:
ActiveWorkbook.FollowHyperlink "C:\Test.pdf"
Dim searchString As String
'Create loop using variable i
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
For I = 1 To FinalRow
searchString = Cells(I, 3).Value
'Send "CTRL + F" keys to the opened PDF to invoke find within that file
'The second argument "true" implies that Excel will wait for the keys to be processed before returning control to the macro.
SendKeys "^f", True
'Type the search string in the find box that opens
SendKeys searchString, True
'Hit enter to perform the search
SendKeys "{Enter}", True
'Bookmark highlighted text
SendKeys "^b", True
'Hit enter to perform the bookmark
SendKeys "{Enter}", True
Next I
Application.DisplayAlerts = True
End Sub ```