Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlink event to open an Adobe Acrobat PDF file

Status
Not open for further replies.

rccline

Technical User
Jun 13, 2002
341
US
Reference:

Referencing the above links, I find that I can get the click event (run from a command button on my input form) to open the named file (Document.pdf).

My table is tblIndex and the file name is field FileName. I also have a field named path with the filename as part of the path.

What is working is this:

Code:
Private Sub Command0_Click()
 
   Shell ("C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\acrobat.exe C:\Users\Mypath\Document.pdf"), vbMaximizedFocus

End Sub


I would like to be able to set a hyperlink click event on a control on my form that corresponds with the current record based upon the file name that changes with each record to open an adobe acrobat document in a different window.

I don't know how to do this.

Code:
Private Sub Command0_Click() 
    Dim strFileName As String    
    strFileName = tblIndex.FileName
   
    Shell ("C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\acrobat.exe C:\Users\rccline\Mypath\Document.pdf"), vbMaximizedFocus
End Sub


It seems simple enough, but it is over my head.

Thank you for assistance with this.

rccline
 
Is that what you are trying to accomplish:
Code:
Private Sub Command0_Click() 
    Dim strFileName As String    
    strFileName = tblIndex.FileName
   
    Shell ("C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\acrobat.exe C:\Users\rccline\Mypath\[blue]" & strFileName[/blue]), vbMaximizedFocus
End Sub

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Yes Alex.... that is what I was looking for. Thank you.

However, I am getting an error OnClick.

The field "FileName" is set to hyperlink.

The text box for the field name does not show it as a hyperlink.

On click event, I am getting an Error. The message box that displays is shown below. There are no events that run when I open my form.

Robert
 
 http://files.engineering.com/getfile.aspx?folder=039fd406-a156-4d30-8927-c54fa02cb377&file=Hyperlink_clickevent_Error.jpg
After the Error message shown in the attachedjpg appears. I click OK. A circular process bar runs and I get the follwing message:


Unable to open Cannot locate the Internet server or proxy server.

So, it is giving me the FileName for the record that is displaying on the form. That record is what should be represented by strFileName.

Code:
 Shell ("C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\acrobat.exe C:\Users\rccline\Mypath\" & strFileName), vbMaximizedFocus
 
I am trying to open a link to Acrobat DC to a specific page in Adobe Acrobat DC.

Andy responded with revised syntax to call strFileName into the Shell command. I cannot verify if this is correct as the code still will not run. Can anyone explain what is happening here?

Thank you.

Rccline
 
If you are ever looking to open a web based pdf, here's a great way to do it.
Code:
      Dim varHyper As Variant
varHyper = "[URL unfurl="true"]http://www.statlab.com/skin/frontend/default/statlab/inc/catalog/statlab_catalog_2015.pdf"[/URL]
    
Application.FollowHyperlink varHyper

If you already have the link in the database, you can slightly modify your code as follows.

Code:
     Dim varHyper as Variant

varHyper = Me.FieldName 'if you're on the same form.

varHyper = Forms!frmName!FieldName 'if you're not on the same form.

Application.FollowHyperlink varHyper

I hope this helps.
 
Part of the problem is that Filename appears to actually contain filenames not hyperlink URLs (they are not the same thing), and so the value returned from the textbox is " which won't work.

So can you please be explicit about what you want to do? Are you simply trying to open a file available on the local filesystem, or are you actually trying to open a file from a webserver?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top