Lockie2000
New Member
- Joined
- Apr 27, 2012
- Messages
- 1
Hi,
I am trying to hyperlink about 10,000 files using VBA as. The following cells contain:
B1 = The path to the files to be linked (I named the cell range Path)
B3:B10003 = the filenames of all the pdfs (eg. Document1.pdf)
This is the code i have done but it isnt working (i am new to VBA)
Sub Macro2()
Dim FilePath, Cell, FPCell As String
FilePath = Range("Path").Value + "\"
Cell = ActiveCell.Value
FPCell = FilePath & Cell
ActiveCell.Offset(2, 1).Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Cell, Address:= _
FPCell, TextToDisplay:=Cell
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Cell, Address:= _
FPCell, TextToDisplay:=Cell
Do Until ActiveCell.Offset(0, 0).Value = ""
If ActiveCell.Offset(0, 0).Value = "" Then [A1].Select: Exit Sub
Loop
End Sub
The reason i have the path in cell B1 is because the path changes depending on which computer is being used.
Also my home computer is a 64bit but my work computer is 32bit, does this matter with the coding?
Any help would be greatly appreciated.
Thanks.
I am trying to hyperlink about 10,000 files using VBA as. The following cells contain:
B1 = The path to the files to be linked (I named the cell range Path)
B3:B10003 = the filenames of all the pdfs (eg. Document1.pdf)
This is the code i have done but it isnt working (i am new to VBA)
Sub Macro2()
Dim FilePath, Cell, FPCell As String
FilePath = Range("Path").Value + "\"
Cell = ActiveCell.Value
FPCell = FilePath & Cell
ActiveCell.Offset(2, 1).Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Cell, Address:= _
FPCell, TextToDisplay:=Cell
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Cell, Address:= _
FPCell, TextToDisplay:=Cell
Do Until ActiveCell.Offset(0, 0).Value = ""
If ActiveCell.Offset(0, 0).Value = "" Then [A1].Select: Exit Sub
Loop
End Sub
The reason i have the path in cell B1 is because the path changes depending on which computer is being used.
Also my home computer is a 64bit but my work computer is 32bit, does this matter with the coding?
Any help would be greatly appreciated.
Thanks.