Open PDF file from filename stored in cell

a_sanchez

New Member
Joined
Apr 22, 2002
Messages
5
I have a searchable data range which points to several PDF files, so I can open them after finding references in Excel.
The question is: Is there a way to open the selected file from within excel via VB?
Please help.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
On 2002-04-23 13:10, a_sanchez wrote:
I have a searchable data range which points to several PDF files, so I can open them after finding references in Excel.
The question is: Is there a way to open the selected file from within excel via VB?
Please help.

Maybe I'd said that I don't want to open the file directly in excel, just give the "order" to AcrobatReader to activate and open the file.
Hope it helps to clarify.
 
Upvote 0
can i ask why you wish to do this, is the pdf file reference material, if so can this not be put in excel in own sheet so hyperlink can be used or in own WkBk and opened/viewed...

just finding some back ground

PS what version of Adobe wre the PDF files constructed in or where the bastardised in to pdf... i ask as you only want to view them, so i ask where did these files come from...

yes this does matter.. ill explain.
 
Upvote 0
Thanks for your answer.
The PDF files came on technical data cd which doesn't work anymore, so I put them in a folder in HD. I created an index so I can search for reference and excel points to filename to open. At this point I switch to Reader and open file.
I'd like to point to reference in Excel and open the Reader's file.
 
Upvote 0
On 2002-04-25 21:49, a_sanchez wrote:
Thanks for your answer.
The PDF files came on technical data cd which doesn't work anymore, so I put them in a folder in HD. I created an index so I can search for reference and excel points to filename to open. At this point I switch to Reader and open file.
I'd like to point to reference in Excel and open the Reader's file.

When you say index / points to filename
I'm assuming you mean you have the Full file
name listing in the rows ??
eg.

<HTML><HEAD><STYLE TYPE="text/css"></STYLE><TITLE></TITLE></HEAD><BODY bgcolor="#9F9F9F" ><FONT FACE="arial, helvetica, sans-serif"><LEFT><TABLE bgcolor="#FFFFFF" Border=2><TR><TD Align=Right bgcolor="#DFDED0">
</TD><TD Align=Center bgcolor="#DFDED0">A</TD></TR><TR><TD Align=Right bgcolor="#DFDED0">1</TD><TD Align=Right >C:MySiteaccessing-biz-services_.pdf</TD></TR><TR><TD Align=Right bgcolor="#DFDED0">2</TD><TD Align=Right >C:MySiteDirect Debit Form.pdf</TD></TR><TR><TD Align=Right bgcolor="#DFDED0">3</TD><TD Align=Right >C:MySiteGMShare.pdf</TD></TR><TR><TD Align=Right bgcolor="#DFDED0">4</TD><TD Align=Right >C:MySiteOverview Ops Improvement12.01.pdf</TD></TR><TR><TD Align=Right bgcolor="#DFDED0">5</TD><TD Align=Right >C:MySitereadme.pdf</TD></TR><TR><TD Align=Right bgcolor="#DFDED0">6</TD><TD Align=Right >C:MySiteshorteval.pdf</TD></TR><TR><TD Align=Right bgcolor="#DFDED0">7</TD><TD Align=Right >C:MySiteSpreadSheet Modelling Best Practice.pdf</TD></TR><TR><TD Align=Right bgcolor="#DFDED0">8</TD><TD Align=Right >C:MySitetemplates2.pdf</TD></TR></TABLE></LEFT></BODY>

This table was created by a free Excel macro written by <A HREF ="MAILTO:charlie@balch.org">Charles Balch</A>Here's the <A HREF = "http://www.gwds.co.nz/">code</A>. It is care ware - it's yours for free if do something nice for anyone.
Amended @ <A HREF = "http://www.gwds.co.nz/"> http://www.gwds.co.nz/ </A>. This File is currently - being amended for the Boards users by <A HREF = "MAILTO:ivanmoala@xtra.co.nz">Ivan F Moala</A>.

</HTML>

If so then this may help you;

<pre/>
Option Explicit

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal Hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


Sub Open_Pdf_FromList()
Dim sPdfFile As String
Dim sFDir As String
Dim X

'// Get Full PDF FileName from Activecell
sPdfFile = ActiveCell.Text
If sPdfFile = "" Then GoTo Check1
If Dir(sPdfFile) = "" Then GoTo Check2

'// Get Directory name Only
X = Split(sPdfFile, Application.PathSeparator)
ReDim Preserve X(0 To UBound(X) - 1)
sFDir = Join(X, Application.PathSeparator) & Application.PathSeparator

'// Get FileName Only
X = Split(sPdfFile, Application.PathSeparator)
sPdfFile = X(UBound(X))

'// Now Open PDF File
ShellExecute 0, "Open", sPdfFile, "", sFDir, 1

Exit Sub
Check1:
MsgBox "Cell is Empty!"
Exit Sub
Check2:
MsgBox sPdfFile & vbCrLf & vbCrLf & "Is not valid or does not exist"
End Sub
</pre>

Just select the cell reference and run this macro.....
 
Upvote 0

Forum statistics

Threads
1,213,515
Messages
6,114,080
Members
448,548
Latest member
harryls

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