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.

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:temptest.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:temptest.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:temptest.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

120+ Professional Project Management Templates!
Save Up to 85% LIMITED TIME OFFER

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

Browse All Templates
Excel VBA Project Management Templates

All-in-One Pack
120+ Project Management
Premium Templates
View Details

Essential Pack
50+ Project Management
Premium Templates
View Details
50+ Excel
Project Management
Templates Pack
View Details
50+ PowerPoint
Project Management
Templates Pack
View Details
25+ MS Word
Project Management
Templates Pack
View Details
Ultimate Project Management Template
View Details
Ultimate Resource Management Template
View Details
Project Portfolio Management Templates
View Details
By Last Updated: June 17, 2022Categories: VBATags:

Share This Story, Choose Your Platform!

Leave A Comment