Opening a PDF document from within an Excel file

Wessie

Board Regular
Joined
Jul 31, 2013
Messages
150
Hi all

I have a quick question that is puzzling me.

I want to attach a PDF help file on an Excel file / sheet / workbook that is fully portable. I want to program a button on a userform that will open this PDF document, and if possible, make the PDF file accessible if you press the F1 help button. Can anyone help me with the coding and implementation in this regard?

Thank you in advance for your assistance.
Kind regards
R
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
The file must be fully portable as one file. Otherwise the path must always be specified or the PDF file always in a specific location. Therefore it cannot be sent via email at all.
 
Upvote 0
This macro could be included in your Personal workbook file, as a part of the Open event, so that it runs every time that Excel is started. The macro should contain a single command:
Code:
Application.OnKey "{F1}", ""
The OnKey method is only triggered, in this case, when the F1 key is pressed. This usage results in the F1 key being ignored. If you wanted the F1 key to run some different procedure, you could use it as follows:
Code:
Application.OnKey "{F1}", "MyProcedure"

As for opening the pdf, something like this should work.

Code:
Dim myShell As ObjectSet myShell =  CreateObject("WScript.Shell")
myShell.Run "K:\PDF\mypdf.pdf"
 
Upvote 0
not quite sure i understand fully portable
does it come with the workbook?

if so
Code:
Sub openPDf()
    
    Dim myShell As Object
    Set myShell = CreateObject("Shell.Application")
    
    myShell.Open (ThisWorkbook.Path & "\Help.pdf")
    
End Sub
 
Upvote 0
Thanks Humdingaling. It should be part of the workbook already (as an object for instance). Then I want to execute the object from within the file.

I just want to send one document (the excel) and it should include the PDF already.
 
Upvote 0
Hi Wessie,

This worked for me... Click "Insert" -> "Object" -> "Create From File" -> "Browse" (Select PDF) -> tick "Display Icon" -> "OK"

then the code to open it is;

Code:
Worksheets("Sheet1").OLEObjects(1).Verb

Hope this helps,
Cheers,
Alan.
 
Upvote 0
I found the answer:

You first have to attach the PDF as an object in the worksheet and display it as an icon. After you attached in on file via an object, you insert a button using the following code:

ActiveSheet.Shapes.Range(Array("Object 1")).Select
Selection.Verb Verb:=xlPrimary


When you click on the button the PDF will open.

Thank you for your help.
Kind regards,
R
 
Upvote 0
Hi Wessie,

This worked for me... Click "Insert" -> "Object" -> "Create From File" -> "Browse" (Select PDF) -> tick "Display Icon" -> "OK"

then the code to open it is;

Code:
Worksheets("Sheet1").OLEObjects(1).Verb

Hope this helps,
Cheers,
Alan.


Thank you Alan. That was my resolve as well.
 
Upvote 0

Forum statistics

Threads
1,214,780
Messages
6,121,525
Members
449,037
Latest member
tmmotairi

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