Displaying a PDF file using the AcroPDF controller via a hyper link

gman1979

New Member
Joined
Oct 12, 2007
Messages
35
Hi Guy's,

Windows XP
Excel 2003

this one I’m sure will have a simple solution, but for some reason I can't find one, still pretty new to vba so trying my best her, but spent best part of 5hrs on this and I’m sure I’ve prob wasted allot of time.

The code below easily displays the referenced PDF file in the PDF viewer within my userform1

***this lets me select the PDF file*****
Private Sub CommandButton2_Click()
fileToOpen = Application _
.GetOpenFilename("All xls Files (*.PDF), *.PDF")
If fileToOpen <> False Then
TextBox1.Value = fileToOpen
End If
End Sub

***this then opens the PDF file from the path that was inputted into textbox1


I’ve been trying to do the same with online PDF file (which I have the urls for) but cant get it working, I’ve had read through the related posts on hyper linking and opening them, but they all refer to hyperlinks within cells where I’m just looking to assign an address to a button that when clicked will display the linked PDF file in the viewer


Any ideas

So far I’ve tried the following without success (excuse my ignorance and level of vba knowledge if any of this code looks ridiculous)

Private Sub commandbutton4_click()
Dim linkname As Hyperlink
linkname = TextBox1.Value
AcroPDF1.LoadFile linkname
End Sub

I get runtime error '91'
object variable or with block variable not set


Help!!

Thanks in advance guy's

Gman1979

Private Sub CommandButton1_Click()
AcroPDF1.LoadFile TextBox1.Value
End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top