• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Open excel by vba

Hi EE

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)
Else
    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

chestera
0
chestera
Asked:
chestera
1 Solution
 
akbCommented:
Try:

   Call Shell("""C:\Program Files\Microsoft Office\Office14\excel.exe"" " + """" + strmyfile + """", 1)
0
 
chesteraAuthor Commented:
Thank your for your help works great
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now