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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a pdf file by clicking a command button 2

Status
Not open for further replies.

loloslikes

Programmer
Mar 31, 2003
2
US
I have been trying to open a pdf file by clicking on a command button I created in a dialog box. I am starting to think that I am just barking up the wrong tree.

this is what I have done:
-this code is put into the cmd button's click event procedure

Dim myFile as String, getMyFile as Object

myFile = "location of file on computer.pdf"

getMyFile.OpenFile myFile

What am I doing wrong???
 
loloslikes-

Put the following procedure into a module, save module as "PDF_Files"


Sub Open_PDF_File()

Dim WshShell

Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "C:\File_Name.pdf"

End Sub


In the click event for your button, put the following:


Private Sub CommandButton1_Click()

PDF_Files.Open_PDF_File

End Sub

Hope it helps...
 
Apollo6,
I tried your suggestion but I get an error here:

WshShell.Run "C:\File_Name.pdf"

I did change the path to point to my pdf file. So that's
not my problem...any suggestions

-thanks in advance
 
Since it is working in mine, I would think it may be with the project references. I have several in mine so I'm not sure which one might be the one...
 
loloslikes,

This is the code I have been using,

Private Sub cmdOpenPDF_Click()
Dim MyPath As String
MyPath = Me.filepath
Me.cmdOpenPDF.HyperlinkAddress = MyPath
End Sub

Works great for me. Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top