Jump to content

Recommended Posts

Posted

Is it possible to use variables in the Run function? The example below does not open the file foo.xls. Instead Excel produces an error indicating that it can not open $path.xls.

Run ('"D:\Program Files\Microsoft Office\Office\EXCEL.EXE" /e $path & "foo.xls"', "", @SW_MAXIMIZE)

HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/
Posted (edited)

It is very possible, but you have the variable inside of a string. Try something like:

Run ('"D:\Program Files\Microsoft Office\Office\EXCEL.EXE" /e "' & $path & 'foo.xls"', "", @SW_MAXIMIZE)

Edited by crzftx
Posted

Try:

Run ('"D:\Program Files\Microsoft Office\Office\EXCEL.EXE /e "' &  $path & 'foo.xls"', "", @SW_MAXIMIZE)

Is it possible to use variables in the Run function? The example below does not open the file foo.xls. Instead Excel produces an error indicating that it can not open $path.xls.

Run ('"D:\Program Files\Microsoft Office\Office\EXCEL.EXE" /e $path & "foo.xls"', "", @SW_MAXIMIZE)

Posted

Thanks for the information guys! Unfortunately, I could not get either solution to work. I tried the line below combining the path and file name in one variable. However, I could not get this to work either. obviously, I don't understand what the Run syntax should be with variables! Any ideas?

Run('"D:\Program Files\Microsoft Office\Office\EXCEL.EXE" /e & $path_file_name', "", @SW_MAXIMIZE)

HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/
Posted (edited)

Is it possible to use variables in the Run function? The example below does not open the file foo.xls. Instead Excel produces an error indicating that it can not open $path.xls.

Run ('"D:\Program Files\Microsoft Office\Office\EXCEL.EXE" /e $path & "foo.xls"', "", @SW_MAXIMIZE)

Run ('"D:\Program Files\Microsoft Office\Office\EXCEL.EXE" /e $path & "\foo.xls"', "", @SW_MAXIMIZE)

Try using this format:

$Path = @MyDocumentsDir
Run($Path & '\My document.xls')
Edited by JamesBrooks
Posted

Thanks to all for the help! After some additional research, I was able to get the following Run statement to work:

Run('"D:\Program Files\Microsoft Office\Office\EXCEL.EXE" /e "' & $path_file_name & '"', "", @SW_MAXIMIZE)

But not sure I understand why! :-)

HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...