Hyperlink

  • Thread starter Sri via OfficeKB.com
  • Start date
S

Sri via OfficeKB.com

Hello

I am writing a VB macro in Excel to populate some folder structures in few
cells. I would like to have these cells as hyperlinks so that one can click
on this cell to directly open that folder. Could anybody help me how to write
a hyperlink text in a cell through VB macro.

For example, my macro writes "C:\Documents and Settings\All Users" string
into cell A1. It should be written as a hyperlink so that user could go there
by simply clicking on the cell.

Please help.

Sri
 
M

Mike H

Try this

Hyperlinks.Add Anchor:=Range("A1"), Address:= _
"C:\Documents and Settings\All Users", TextToDisplay:= _
"""C:\Documents and Settings\All Users"""

Mike
 
G

Gary''s Student

Say test is a folder in the C: drive

Sub HyperPlacer()
Dim s As String
s = "=HYPERLINK(""file:///C:\test"")"
Range("A1").Formula = s
End Sub

will place a hyperlink in A1. When clicked the folder will open.
 
B

brzak

Hello

I am writing a VB macro in Excel to populate some folder structures in few
cells. I would like to have these cells as hyperlinks so that one can click
on this cell to directly open that folder. Could anybody help me how to write
a hyperlink text in a cell through VB macro.

For example, my macro writes "C:\Documents and Settings\All Users" string
into cell A1. It should be written as a hyperlink so that user could go there
by simply clicking on the cell.

Please help.

Sri


Sub HyperLinkToFolder()
Dim ShtName as String ' the name of the sheet containing the
hyperlink
ShtName = "Sheet1"

Sheets(ShtName).Hyperlinks.Add _
Anchor:=Sheets(ShtName).range("A1"), Address:= _
"C:\Documents and Settings\All Users", _
TextToDisplay:= "Hyper Link to a folder", _
ScreenTip:="Click Me"

End Sub

Enjoy

Brz
 
S

Sri via OfficeKB.com

Hello all

Thanks for your help.

Could you please help me in applying your method to my requirement.

I am printing my string with the following command.
"Worksheets("Design Steps").Cells(row_no, 7).Cells.Value = test_exec_dir"

How to integrate it with your below suggession (especially Range("A1") )???

Hyperlinks.Add Anchor:=Range("A1"), Address:= _
"C:\Documents and Settings\All Users", TextToDisplay:= _
"""C:\Documents and Settings\All Users"""

Thanks to all
Sri
[quoted text clipped - 13 lines]
Sub HyperLinkToFolder()
Dim ShtName as String ' the name of the sheet containing the
hyperlink
ShtName = "Sheet1"

Sheets(ShtName).Hyperlinks.Add _
Anchor:=Sheets(ShtName).range("A1"), Address:= _
"C:\Documents and Settings\All Users", _
TextToDisplay:= "Hyper Link to a folder", _
ScreenTip:="Click Me"

End Sub

Enjoy

Brz
 
Top