Insert/Embed PDF File automatically via VBA


B

Brad

I'm trying to create a little program where it will allow a user to embed a
PDF file so we can maintain records. I've done the record macro and recorded
the action of Insert->Object->Create from File, however it forces you to
select a file. And in the code, it puts the file name you select. This is an
issue as the user may save the PDF file as a different name than
preprogrammed. So is it possible to have VBA automatically open the
Insert->Object->Create from File->Browse file box to allow the user to select
the PDF file? Below is the code to automatically add a prenamed PDF file and
it works fine, just doesn't give the user the option to select the file they
want to insert. Thanks in advanced.

------------------------
Sub Macro3()
'
' Macro3 Macro
' Macro recorded 8/5/2008 by bhodge
'

'
ActiveSheet.OLEObjects.Add(Filename:= _
"C:\Documents and Settings\bhodge\Desktop\test2.pdf", Link:=False, _
DisplayAsIcon:=True, IconFileName:= _

"C:\WINDOWS\Installer\{AC76BA86-7AD7-1033-7B44-A70000000000}\PDFFile.ico", _
IconIndex:=0, IconLabel:= _
"C:\Documents and Settings\bhodge\Desktop\test2.pdf").Select
End Sub
 
Ad

Advertisements

A

Ak Man

MsgBox "Enter the your file"
MyFile = Application.GetOpenFilename
If MyFile = "False" Then Exit Sub

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top