Consulting

Results 1 to 5 of 5

Thread: Solved: Open pdf or image file from predefined folder

  1. #1
    VBAX Tutor
    Joined
    Feb 2008
    Location
    New York
    Posts
    215
    Location

    Solved: Open pdf or image file from predefined folder

    Hello all,

    I am in need of tracking all scanned documents and pictures, so I am wondering if someone would be kind enough to have a look at the attached files. In the attached excel table in column B, has the list of Document Name. What I am looking for is, when a user selected the file name from Column B and presses "View Doc" button, then the file should open. I would be putting all the files and picture in the folder named "DocumentLibrary". Can someone please help? Thanks.
    -u

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    The attachment uses a change event to show the images
    [vba]Sub AddPic()
    Dim Pth As String
    On Error Resume Next
    ActiveSheet.Pictures(1).Delete
    Err = 0
    Pth = ActiveWorkbook.Path
    ActiveSheet.Pictures.Insert(Pth & "\DocumentLibrary\" & ActiveCell.Text & ".jpg").Select
    If Err = 1004 Then GoTo Exits
    With Selection
    .ShapeRange.Left = [F3].Left
    .ShapeRange.Top = [F3].Top
    End With
    Exits:
    End Sub
    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Tutor
    Joined
    Feb 2008
    Location
    New York
    Posts
    215
    Location
    hi mdmackillop,

    thanks for the attachment. your code brings up the picture amazingly but I am looking to open the picture or the pdf to open from it own program if it's possible. I also noticed the I am not able to open pdf files from the code.

    i need to be able to open pictures from application like windows picture manager (or computer's default picture program) and pdf files to open from acrobat (the pdf files would have more than one page). can you please help? Thanks.
    -u

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Use FollowHyperlink, but you'll need to get the correct extension for each file. Check out the Dir command for this.
    [vba] ActiveWorkbook.FollowHyperlink Pth & "\DocumentLibrary\" & ActiveCell.Text & ".jpg"
    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Tutor
    Joined
    Feb 2008
    Location
    New York
    Posts
    215
    Location
    Thanks.
    -u

Posting Permissions

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