Opening Different File Types

To open files that belong to an application other than Excel, you can automate the other application. If you just want to open them, however, the FollowHyperlink method of the Workbook object is a better choice. Way less overhead. FollowHyperlink isn’t just for HTML files, it works with any file. It has the added advantage of figuring out which application to open. I assume it uses the Windows settings to determine that.

Run a sub like this

Sub OpenFiles()

    Dim sPath As String
   
    sPath = “C:Documents and SettingsDickMy Documents”
   
    With ThisWorkbook
        .FollowHyperlink sPath & “db1.mdb”
        .FollowHyperlink sPath & “Mod.xls”
        .FollowHyperlink sPath & “WordsList.txt”
        .FollowHyperlink sPath & “Doc1.doc”
    End With
   
End Sub

and you can have a taskbar that looks like this

Followhlink

Posted in Uncategorized

One thought on “Opening Different File Types

  1. Thanks, I tried to use this in my 12-line mini Excel 2003 VBA script this morning.. I was searching for ShellExecute and came to another post in your blog and saw the link to this post and figured I’d tried it. Worked like a charm! Except for the Warning “Hyperlinks can be harmful to your computer…” and there was another warning after that.. I poked around in Tools Options and couldn’t figure out where to turn those off, so I went back to ShellExecute.


Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.