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

Excel form to open pdf file? Need for Read/Only users

Status
Not open for further replies.

TomYC

Technical User
Dec 11, 2008
191
US
I have an Excel form that uses vba to generate a pdf file, and display it.
However for some users I want to place this form/dashboard file in a Read/Only environment and have the button on the form pull up the relevant pdf files (in a loop) that have already been created.
My current code includes:

Application.DisplayAlerts = False
'ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FullName _
, Quality:=xlQualityMedium, IncludeDocProperties:=False, _
IgnorePrintAreas:=False, OpenAfterPublish:=True


Application.DisplayAlerts = True

Thus, the file fulfilling the criteria "FullName.pdf" is the one I want the code to pull up, as opposed to Export as a pdf, since such a pdf file with that name already exists.
Is there not some simple code I can replace the above with that will pull up what I need?
T.Y.
 
If you want to start Adobe reader and show your pdf file, you may do something like this:

Code:
Dim strAdobeEXE As String
Dim strFileToDisplay As String

strAdobeEXE = "C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32"
strFileToDisplay = "C:\Temp\README.pdf"

Shell (strAdobeEXE & " " & strFileToDisplay)

Have fun.

---- Andy
 
Or you can use this code to open any file with its associated application, so txt would be open in Notepad, xls with Excel, doc with Word, etc. You just pass a document name with its path:

Code:
Public Sub OpenDocument(DocumentWithPath As String)
Dim L As Long
L = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & DocumentWithPath, vbNormalFocus)
End Sub

Have fun.

---- Andy
 
Djienkuye, Andy!
Actually, it was even easier than that:

ActiveWorkbook.FollowHyperlink FullName, NewWindow:=True
 

Prosze bardzo, Tomek :)

Well, it is easier if you already have the Hyperlink to the file :)

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top