PDA

View Full Version : Solved: Open pdf or image file from predefined folder



U_Shrestha
04-15-2008, 12:50 PM
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.

mdmackillop
04-15-2008, 02:41 PM
The attachment uses a change event to show the images
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

U_Shrestha
04-15-2008, 06:04 PM
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.

mdmackillop
04-16-2008, 12:48 AM
Use FollowHyperlink, but you'll need to get the correct extension for each file. Check out the Dir command for this.
ActiveWorkbook.FollowHyperlink Pth & "\DocumentLibrary\" & ActiveCell.Text & ".jpg"

U_Shrestha
04-16-2008, 01:08 PM
Thanks.