• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Open PDF including search term - goto first search result (command line?)

New Here ,
Jun 12, 2021 Jun 12, 2021

Copy link to clipboard

Copied

How can I open a given PDF file while starting a search for a certain string within the file?

 

I have to check several invoices which came just together in one container file. Moreover, I have an Excel file (XLSX) listing all relevant invoice numbers.

 

From the Excel file I can perform task like "open pdf" oder "run acrobat". However, I do not know how I can tell Acrobat not only to open my container PDF but also start searching a given invoice number whithin this PDF (it is very time consuming re-entering all relevant invoice numbers into the search dialog of Acrobat).

 

I could not find any command line switches for opening a PDF with Acrobat.exe while performing a search. And I am not familiar with the capabilities of scripting whithin Acrobat.

 

Therefore I would be glad to get help on how to "link" the PDF to my XLSX - whithout re-entering the invoice numbers.

 

Kind regards.

TOPICS
How to , JavaScript , Standards and accessibility

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2021 Jun 12, 2021

Copy link to clipboard

Copied

You can't quite do that, but you can do something similar. You can cause the Advanced Search window to open and search for a specific string when opening the file. From the results you could then jump to the location of the first match, by manually double-clicking it.

To do it execute the following command (through Shell, for example):

 

"<Path to Acrobat.exe on your machine>" /A "search=<Search term>" "<Path to the PDF file>"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 12, 2021 Jun 12, 2021

Copy link to clipboard

Copied

Thank You very much!

 

This is what I was looking for and Your hint works for me! Thus I can avoid retyping the invoice numbers within the Acrobat search.

 

By the way: Where did You find the "/A search" start parameter for Acrobat.exe? Is there any document available? I tried a search myself but found nothing...

 

Kind regards.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2021 Jun 12, 2021

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

Hi, it's me again. Thanks for linking the document.

 

Finally, I managed my challenge by the following:

 

In Excel I have a two column setting: In Column $A are my search terms, in Column $B is a neutral hyperlink "file:\\\#" ... it does nothing except being a clickable hyperlink.

 

Excel_Hyperlink.png

 

Because the Excel HYPERLINK() function does not allow to run external programs like ACROBAT.EXE I had to find this workaround.

 

Within the VBA window I use the event WORKSHEET_FOLLOWHYPERLINK() for finetuning my search:

 

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

    Const Path_Acrobat As String = "C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe"
    Const Path_PDFFile As String = "C:\(insert path here)\document.pdf"
    Const Run_Param As String = "search="
    Dim Str_Search As String
    Dim Str_CMD As String
    
    Dim wsh As Object
    Set wsh = VBA.CreateObject("WScript.Shell")
    Dim waitOnReturn As Boolean: waitOnReturn = True
    Dim windowStyle As Integer: windowStyle = 1
    
    Str_Search = ActiveCell.Offset(rowOffset:=0, columnOffset:=-1).Value
    Str_CMD = Chr(34) & Path_Acrobat & Chr(34) & " /A " & Chr(34) & Run_Param _
        & Str_Search & Chr(34) & " " & Chr(34) & Path_PDFFile & Chr(34)
    wsh.Run Str_CMD, windowStyle, waitOnReturn
        
End Sub

 

this code picks the content of the left cell as search term within the PDF file. Because the hyperlink is empty the TARGET is of use whithin this code.

 

Please be careful: this code is some quick work... there are a lot of very skilled programmers around who might have much better solutions.

 

Kind regards!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

LATEST

EDIT: ...is of NO use whithin...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines