Trouble after third loop, looking for alternatives to send keys

53 views Asked by At

So I am looking to automatically bookmark a PDF. I am having success executing the first few loops, but then it glitches after and does not bookmark the correct location. As well, I would like to know if there are better alternatives to the ^f and ^b. Here is the code I have so far:


    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 ``` 


0

There are 0 answers