Access MVP (2010-2015)


FollowHyperlink to file regardless of File Extension

To open a file regardless of the File Extension you can use…

The below is run from a Command Button on a Form the has a Control listing all the files in said directory.

Windows XP…

     Dim strFileName As String
     strFileName = Dir("C:\Documents and Settings\Regina Whipp\My Documents\YourFolcer\" & Me.FieldOnYourFormThatHasFileName & "*")
     Application.FollowHyperlink ("C:\Documents and Settings\Regina Whipp\My Documents\YourFolder\" & strFileName

Windows 7…

     Dim strFileName As String

     strFileName = Dir("C:\Users\YourUserName\Documents\YourFolder\" & Me.FieldOnYourFormThatHasFileName & "*")
     Application.FollowHyperlink ("C:\Users\YourUserName\Documents\YourFolder\" & strFileName

P.S. Make sure you change the names of *YourFolder* and *YourUserName* to match your machine or your Users machine.  You do want to add some code to handle opening a File that has an extension for a program not available to the User.

Side Note: Why did I just put this all on one line… because FollowHyperlink cannot translate Wildcards.

 1,347 total views,  1 views today

Comments are closed.