-
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.
-
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'
-
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.
-
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'
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules