INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Hyperlink event to open an Adobe Acrobat PDF file

Hyperlink event to open an Adobe Acrobat PDF file

(OP)
Reference:
http://www.tek-tips.com/viewthread.cfm?qid=1139663
http://www.tek-tips.com/viewthread.cfm?qid=1257256

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

RE: Hyperlink event to open an Adobe Acrobat PDF file

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\" & strFileName), vbMaximizedFocus
End Sub 

Have fun.

---- Andy

There is a great need for a sarcasm font.

RE: Hyperlink event to open an Adobe Acrobat PDF file

(OP)
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

RE: Hyperlink event to open an Adobe Acrobat PDF file

(OP)
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 http://FileName.pdf 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 

RE: Hyperlink event to open an Adobe Acrobat PDF file

(OP)
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

RE: Hyperlink event to open an Adobe Acrobat PDF file

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 = "http://www.statlab.com/skin/frontend/default/statlab/inc/catalog/statlab_catalog_2015.pdf"
    
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.

RE: Hyperlink event to open an Adobe Acrobat PDF file

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 "http://<filename>;" 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?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close