Jump to content
Sign in to follow this  
HeidiR

Using Variables in the Run Function

Recommended Posts

HeidiR

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/

Share this post


Link to post
Share on other sites
crzftx

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

Share this post


Link to post
Share on other sites
DaRam

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)

Share this post


Link to post
Share on other sites
HeidiR

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/

Share this post


Link to post
Share on other sites
James

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

Share this post


Link to post
Share on other sites
HeidiR

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/

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×