Open a File using FollowHyperlink Method

Home/VBA/Open a File using FollowHyperlink Method

VBA code to open a file using Followhyperlink method will help you opening a workbook or anything using Excel VBA. VBA open file example we will see how to open a excel workbook using VBA.

PREMIUM TEMPLATES LIMITED TIME OFFER

ON SALE80% OFF

BROWSE ALL TEMPLATES

50+ Project Management Templates Pack
Excel PowerPoint Word

VIEW DETAILS

Advanced Project Plan & Portfolio Template
Excel Template

VIEW DETAILS

Ultimate Project Management Template
Excel Template

VIEW DETAILS

20+ Excel Project Management Pack
Excel Templates

VIEW DETAILS

20+ PowerPoint Project Management Pack
PowerPoint Templates

VIEW DETAILS

10+ MS Word Project Management Pack
Word Templates

VIEW DETAILS


VBA Code to Open a File using FollowHyperlink Method

Followhyperlink method is very interesting technique available in Excel VBA. This will help us to open anything or any application in default application. Following are the example VBA syntax and VBA code to open a file using Followhyperlink method in Excel VBA.

vba open file

VBA Code to Open a File using FollowHyperlink Method : Syntax

Followhyperlink method of Excel Workbook to open any file, website, or folder. Here is the syntax, we need to specify the file path to open.


ThisWorkbook.FollowHyperlink ("C:\temp\test.xlsx")

Examples of VBA Code to Open a File using FollowHyperlink Method

The following examples will show you how to use FollowHyperlink method of Excel workbook to open different applications.

VBA Code to Open a Excel File using FollowHyperlink Method:
The following Excel VBA code example is to opening a excel file using VBA Followhyperlink method.

Sub sbVBA_To_Open_Excel_File_FollowHypderlink()
    Dim strFilePath As String
    strFilePath = "C:\temp\test.xls"
    ThisWorkbook.FollowHyperlink (strFilePath)
End Sub

Explained VBA Code to Open a Excel File using FollowHyperlink Method:

‘Excel VBA code/procedure to Open a File using FollowHypderlink method
Sub sbVBA_To_Open_Excel_File_FollowHypderlink_C()
‘Declaring a variable strFilePath as string to cappture the file path
Dim strFilePath As String

‘Asigning the File Path to the Variable created above
strFilePath = “C:\temp\test.xls”

‘Opening the file using FollowHyperlink method of Workbook
ThisWorkbook.FollowHyperlink (strFilePath)

‘Ending the sub procedure
End Sub

VBA open file related Examples:

VBA Code to Open a website URL using FollowHyperlink Method:

Sub sbVBA_To_Open_Website_URL_FollowHypderlink()
    Dim strURL As String
    strURL = "analysistabs.com"
    ThisWorkbook.FollowHyperlink (strURL)
End Sub

Explained VBA Code to Open a website URL using FollowHyperlink Method:

‘Excel VBA code/procdure to Open an URL using FollowHypderlink method
Sub sbVBA_To_Open_Website_URL_FollowHypderlink_C()
‘Declaring a variable strURL as string to capture the URL
Dim strURL As String

‘Asigning the URL to the Variable created above
strURL = “analysistabs.com”

‘Opening the URL using FollowHyperlink method of Workbook
ThisWorkbook.FollowHyperlink (strURL)

‘Ending the sub procedure
End Sub

VBA Code to Open a Folder using FollowHyperlink Method:

Sub sbVBA_To_Open_Folder_FollowHypderlink()
    Dim strFolderPath As String
    strFolderPath = "C:\temp\"
    ThisWorkbook.FollowHyperlink (strFolderPath)
End Sub

Explained VBA Code to Open a Folder using FollowHyperlink Method:

‘Excel VBA code/procdure to Open a Folder using FollowHypderlink method
Sub sbVBA_To_Open_Folder_FollowHypderlink()

‘Declaring a variable strFolderPath as string to capture the Folder path
Dim strFolderPath As String

‘Asigning the Folder path to the Variable created above
strFolderPath = “C:\temp\”

‘Opening the Folder path using FollowHyperlink method of Workbook
ThisWorkbook.FollowHyperlink (strFolderPath)

‘Ending the sub procedure
End Sub

LIMITED TIME OFFER - Get it Now!
Advanced Project Plan Excel Template

 
Related Resource External VBA Reference
By |April 22nd, 2014|VBA|0 Comments

About the Author:

PNRao is a passionate business analyst and having close to 10 years of experience in Data Mining, Data Analysis and Application Development. This blog is his passion to learn new skills and share his knowledge to make you expertise in Data Analysis (Excel, VBA, SQL, SAS, Statistical Methods, Market Research Methodologies and Data Analysis Techniques).

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.