PDA

View Full Version : FollowHyperlink problem



nany
08-08-2007, 12:59 AM
FollowHYperlink
Hello
I've an excell file with all the documents that I need, for my job. For each document, i've a hyperlink. It works, but i'm trying to use the expression"Followhyperlink" to open each document that I want, by selecting with the mouse ,the row were my document is descrived and than by clicking in a commandbutton, the document will appears.
I've all the documents in one folder (D:\S?lvia\TEST\).

For now, what I have done it's this:

Sub OpenFileOrFolder()
Dim strPDFFile As String, strFolder As String

strFolder = "D:\S?lvia\TEST\"
strPDFFile = strFolder & "Test_1_0_0_2000.pdf"
strPDFFile = strFolder & "Test_2_0_0_2000.pdf"
strPDFFile = strFolder & "Test_3_0_0_2000.pdf"


'Open Folder
ActiveWorkbook.FollowHyperlink Address:=strFolder, NewWindow:=True
'Open PDF file
ActiveWorkbook.FollowHyperlink Address:=strPDFFile, NewWindow:=True
'************************************************************************** ****
End Sub

And it doesn't work!!
Can anybody help me?
Thanks

Bob Phillips
08-08-2007, 01:08 AM
Doesn't work? In what way, does it crash and burn, trash the PC, or what?

And your name is pretty poor subject for a posting.

mdmackillop
08-08-2007, 02:35 AM
Your code will only open the last file as the variable is being overwritten. You need to loop through the file names such as
Option Explicit
Sub OpenFileOrFolder()
Dim strPDFFile As String, strFolder As String
Dim Fls, F
Fls = Array("Test_1", "Test_2", "Test_3")
strFolder = "D:\S?lvia\TEST\"
For Each F In Fls
strPDFFile = strFolder & F & "_0_0_2000.pdf"
'Open PDF file
ActiveWorkbook.FollowHyperlink Address:=strPDFFile, NewWindow:=True
Next
End Sub

Edit: Your post has been retitled.

nany
08-08-2007, 04:49 AM
Thank you for your help.

nany