HeidiR Posted July 23, 2008 Share Posted July 23, 2008 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/ Link to comment Share on other sites More sharing options...
crzftx Posted July 23, 2008 Share Posted July 23, 2008 (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 July 23, 2008 by crzftx Link to comment Share on other sites More sharing options...
DaRam Posted July 23, 2008 Share Posted July 23, 2008 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) Link to comment Share on other sites More sharing options...
HeidiR Posted July 23, 2008 Author Share Posted July 23, 2008 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/ Link to comment Share on other sites More sharing options...
James Posted July 23, 2008 Share Posted July 23, 2008 (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 July 23, 2008 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
HeidiR Posted July 23, 2008 Author Share Posted July 23, 2008 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/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now