Open excel by vba

Posted on 2014-08-01
Last Modified: 2014-08-01

I have the following to open a file in excel
Dim xFSO As Object
Dim Tfolder, strMyFile
strMyFile = "C:\AnnualReport\FinancialReport.xls"
Tfolder = "C:\Program Files (x86)"
Set xFSO = CreateObject("Scripting.FileSystemObject")
If Not xFSO.FolderExists(Tfolder) Then
    Call Shell("C:\Program Files\Microsoft Office\Office14\excel.exe ""strmyfile""", 1)
    Call Shell("C:\Program Files (x86)\Microsoft Office\Office14\excel.exe ""strmyfile""", 1)
End If

excel opens but warns it can't find the file stmyfile. I have an idea the quotes are incorrect. Any help appreciated

Question by:chestera
    LVL 13

    Accepted Solution


       Call Shell("""C:\Program Files\Microsoft Office\Office14\excel.exe"" " + """" + strmyfile + """", 1)

    Author Closing Comment

    Thank your for your help works great

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now