Easily open any file, folder, or webpage by using the FollowHyperlink Method

Ease of Use


Version tested with


Submitted by:



Will open any file, folder or webpage without the use of binding. 


Say you have a production workbook with the names of files that you work with (word, excel, PDF, etc) to keep track of the files you work on and are stored in a common folder. You could use this code to open any of those without searching through any folders. Or you could open the folder itself using this code. This method also lets you open websites and create new (blank) emails. 


instructions for use


Sub OpenFileOrFolderOrWebsite() 'Shows how to open files and / or folders and / or websites / or create emails using the FollowHyperlink method Dim strXLSFile As String, strPDFFile As String, strFolder As String, strWebsite As String Dim strEmail As String, strSubject As String, strEmailHyperlink As String strFolder = "C:\Test Files\" strXLSFile = strFolder & "Test1.xls" strPDFFile = strFolder & "Test.pdf" strWebsite = "http://www.vbaexpress.com/" strEmail = "mailto:YourEmailHere@Website.com" strSubject = "?subject=Test" strEmailHyperlink = strEmail & strSubject '**************FEEL FREE TO COMMENT ANY OF THESE TO TEST JUST ONE ITEM********* 'Open Folder ActiveWorkbook.FollowHyperlink Address:=strFolder, NewWindow:=True 'Open excel workbook ActiveWorkbook.FollowHyperlink Address:=strXLSFile, NewWindow:=True 'Open PDF file ActiveWorkbook.FollowHyperlink Address:=strPDFFile, NewWindow:=True 'Open VBAX ActiveWorkbook.FollowHyperlink Address:=strWebsite, NewWindow:=True 'Create New Email ActiveWorkbook.FollowHyperlink Address:=strEmailHyperlink, NewWindow:=True '****************************************************************************** End Sub

How to use:

  1. In excel, press Alt+F11 to open the VBE
  2. Right-Click on VBAProject(YourWorkbookName) and click on Insert --> Module
  3. Copy and paste this code in the new module
  4. Change the String variables as necessary
  5. Comment out any of the FollowHyperlink methods to single out whichever method you're interested in
  6. Go back to your excel workbook (or close the VBE)

Test the code:

  1. Press Alt+F8 and select "OpenFileOrFolderOrWebsite"

Sample File:

FollowHyperlink.zip 6.84KB 

Approved by mdmackillop

This entry has been viewed 556 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express