Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to insert hyperlinks

Hi all,

I have a list of file names (including their location and
type of file) in a column in excel. This workbook is
supposed to work as an index for the contents of all files
in it's folder and subfolders

What I want to do is to automatically create hyperlinks to
all files, doing this manually would take a lot of time,
there are more than 1000 files.

I wrote the following code, but the hyperlinks it creates
don't work:

Sub File_hyperlink()
Dim i As Integer
Dim myRange As Range

Set myRange = Selection

With myRange
For i = 1 To .Rows.Count
ActiveSheet.Hyperlinks.Add Anchor:=Selection,
Address:=ActiveCell.Value
ActiveCell.Offset(1, 0).Range("A1").Select
Next i
End With
End Sub

I have two doubts:
1. What should I be including in the cells in order to
produce correct links? currently the cells' content looks
like:
Subfolder1\Subfolder2\Filename.xls
2. If this content is Ok, what should the code be?
Can anyone help?

Thanks in advance,
Felipe
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Macro to insert hyperlinks

Did you try the shell command?

Shell ("excel c:\test.xls")
or
shell("excel" & range("A1"))


"Felipe" wrote in message
...
Hi all,

I have a list of file names (including their location and
type of file) in a column in excel. This workbook is
supposed to work as an index for the contents of all files
in it's folder and subfolders

What I want to do is to automatically create hyperlinks to
all files, doing this manually would take a lot of time,
there are more than 1000 files.

I wrote the following code, but the hyperlinks it creates
don't work:

Sub File_hyperlink()
Dim i As Integer
Dim myRange As Range

Set myRange = Selection

With myRange
For i = 1 To .Rows.Count
ActiveSheet.Hyperlinks.Add Anchor:=Selection,
Address:=ActiveCell.Value
ActiveCell.Offset(1, 0).Range("A1").Select
Next i
End With
End Sub

I have two doubts:
1. What should I be including in the cells in order to
produce correct links? currently the cells' content looks
like:
Subfolder1\Subfolder2\Filename.xls
2. If this content is Ok, what should the code be?
Can anyone help?

Thanks in advance,
Felipe



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Macro to insert hyperlinks

Maybe you can build your hyperlinks like:

file:\\c:\my documents\excel\book1.xls

If I type that in manually, it gets converted to a hyperlink and loads the file
when I click on it.

ActiveSheet.Hyperlinks.Add Anchor:=Selection, _
Address:="file:\\" & ActiveCell.Value

(with no validity checks at all!)


Felipe wrote:

Hi all,

I have a list of file names (including their location and
type of file) in a column in excel. This workbook is
supposed to work as an index for the contents of all files
in it's folder and subfolders

What I want to do is to automatically create hyperlinks to
all files, doing this manually would take a lot of time,
there are more than 1000 files.

I wrote the following code, but the hyperlinks it creates
don't work:

Sub File_hyperlink()
Dim i As Integer
Dim myRange As Range

Set myRange = Selection

With myRange
For i = 1 To .Rows.Count
ActiveSheet.Hyperlinks.Add Anchor:=Selection,
Address:=ActiveCell.Value
ActiveCell.Offset(1, 0).Range("A1").Select
Next i
End With
End Sub

I have two doubts:
1. What should I be including in the cells in order to
produce correct links? currently the cells' content looks
like:
Subfolder1\Subfolder2\Filename.xls
2. If this content is Ok, what should the code be?
Can anyone help?

Thanks in advance,
Felipe


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I insert hyperlinks in blank cells VROSARIO7 Excel Worksheet Functions 6 July 8th 09 05:11 PM
Insert multiple hyperlinks at same time AmyO Excel Discussion (Misc queries) 2 November 19th 07 03:36 PM
insert a hyperlinks into a what-if equations Robert Excel Discussion (Misc queries) 1 October 21st 06 12:20 PM
How do i allow users to insert hyperlinks into a protected sheet Andy Excel Discussion (Misc queries) 0 July 6th 06 02:36 PM
My hyperlinks are adversely effected when I insert new rows. Maryrose Excel Discussion (Misc queries) 0 February 15th 06 08:55 PM


All times are GMT +1. The time now is 03:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"