7 replies
There is of course a millon ways to do this, but perhaps the easiest is to use the Webbrowser control. Place the webbrowser control on the form and then for each command button do the following.
Private Sub cmdPDF1_Click()
Dim strURL1 As String
strURL1 = "c:\readme.pdf"
WebBrowser1.Navigate (strURL1)
End Sub
dim sets up a variable to store the path (one for each file)
strURL1= stores a path & filename to the variable
webbrowser1.navigate (strURL) make the webbrowser control load your variable(file)
Name your controls something meaningful not just 1,2,3 etc.
To add the webbrowser control to your project, you'll click on Project. Then Components, then scroll down to Microsoft Internet Controls. The bad newsis, I'm not sure if this was included in VB5 or just VB6.
Don
by labrat
Doesn't work. Debug hangs on:
WebBrowser1.Navigate (strURL1)
I added the Microsoft Internet Controls as you said. They were there and it added an icon to the tool bar. But is that all I needed to do? All I really want is to start the Acrobat Reader that I will have on the CD.
After adding it to the toolbar on the left; did you drag it onto the form? This will be your browser window. It will act as if you are in Internet Explorer, Acrobat Reader is a plugin for IE, so you'll see the PDF file open within the browser.
Ifyou want to get alot more complicated you can use API calls to launch Acrobat, open the file and then wait until you close Acrobat. Much more involved.
Give it a try and let me know.
Don
by labrat
I tried a few different ways to handle this and I think that I have an easier way. I know it works if Acrobat is installed on the harddrive, not sure about only on the CD.
Private Sub Command1_Click()
Shell "C:\Program Files\Adobe\Acrobat 5.0\Acrobat\acrobat.exe c:\fuses.pdf", vbMaximizedFocus
End Sub
Private Sub Command2_Click()
Shell "C:\Program Files\Adobe\Acrobat 5.0\Acrobat\acrobat.exe c:\readme.pdf", vbMaximizedFocus
End Sub
This forum messes up the formating, the shell command can be all on one line. Basically, shell then a space then "path to acrobat.exe then space then the filename you want to open then ",vbmaximizedfocus. I did a simple form with two command buttons set to shell to two different pdf files andit worked great.
Don
by labrat
Thanks! Never got the webbrowser thing to work--maybe it is only in v6.0 as you said. The shell command is what I used. I used it in this form:
shell "start c:\acrord32.exe \readme.pdf"
I'm not sure what the vbMaximizedFocuse is for. When used, it just blink a blank black window (like a DOS command window?) but then started the reader and displayed the file. I took it out and the file displayed quicker and it didn't look as clunky with the black screen flashing on. Thank again for your help!!
by labrat
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending