VBA/Excel/Access/Word/Excel/Hyperlinks

Материал из VB Эксперт
Перейти к: навигация, поиск

Creates a hyperlink to each worksheet in the workbook excluding the worksheet containing rgLinks.

   <source lang="vb">

Sub CreateLinks()

   Dim rgLinks As range
   Set rgLinks = range("C1")
   Dim ws As Worksheet
   For Each ws In ThisWorkbook.Worksheets
       If ws.name <> rgLinks.Parent.name Then
           rgLinks.Hyperlinks.add rgLinks, ThisWorkbook.name, _
               """ & ws.name & ""!A1", ws.name, ws.name
           Set rgLinks = rgLinks.Offset(1, 0)
       End If
   Next
   Set ws = Nothing

End Sub

</source>
   
  


Using the Follow method of the Hyperlink object(user selecting the hyperlink in the Excel application)

   <source lang="vb">

Sub followLink()

   Worksheets("Sheet3").Hyperlinks(1).Follow

End Sub

</source>