Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 6 of 6

Thread: Open PDF file from filename stored in cell

  1. #1
    New Member
    Join Date
    Apr 2002
    Location
    Mexico
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

  2. #2
    New Member
    Join Date
    Apr 2002
    Location
    Mexico
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.


    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  4. #4
    New Member
    Join Date
    Apr 2002
    Location
    Mexico
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

  5. #5
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

    ****** bgcolor="#9F9F9F" >

    A
    1C:MySiteaccessing-biz-services_.pdf
    2C:MySiteDirect Debit Form.pdf
    3C:MySiteGMShare.pdf
    4C:MySiteOverview Ops Improvement12.01.pdf
    5C:MySitereadme.pdf
    6C:MySiteshorteval.pdf
    7C:MySiteSpreadSheet Modelling Best Practice.pdf
    8C:MySitetemplates2.pdf


    This table was created by a free Excel macro written by Charles BalchHere's the code. It is care ware - it's yours for free if do something nice for anyone.
    Amended @ http://www.gwds.co.nz/ . This File is currently - being amended for the Boards users by Ivan F Moala.



    If so then this may help you;


    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


    Just select the cell reference and run this macro.....
    Kind Regards,
    Ivan F Moala From the City of Sails

  6. #6
    New Member
    Join Date
    Apr 2002
    Location
    Mexico
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thank you very much for kind answer.

    It works nice and smooth.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •