Script on toolbar button to launch file into Excel problem

Discuss and share scripts and script files...
Post Reply
petersboulton
Posts: 157
Joined: 01 Sep 2008 09:54

Script on toolbar button to launch file into Excel problem

Post by petersboulton »

Hi,

I like the new custom toolbar buttons and want to make one that launches the currently selected file in the list view into Excel. This is my 'solution':

Code: Select all

::run '"C:\Program Files\Microsoft Office\Office12\EXCEL.EXE" <curitem>';
However, when I run it Excel does launch, but displays the message "'<curitem>.xlsx' could not be found. Check the spelling of the file name, and verify that the file location is correct."

This tells me that XY must be passing through the literal text "curitem" rather than the path of the current item in its command line to Excel! However, I'm a script newbie, so possibly I'm misunderstanding something along the line and am hoping for some enlightenment! Thanks.

Pete

zer0
Posts: 2676
Joined: 19 Jan 2009 20:11

Re: Script on toolbar button to launch file into Excel problem

Post by zer0 »

What if you used this script:

Code: Select all

OpenWith "C:\Program Files\Microsoft Office\Office12\EXCEL.EXE";
It defaults to currently selected item and supports the full power of OpenWith UDC.
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Script on toolbar button to launch file into Excel problem

Post by Stefan »

This quoting tricked me always too, but it seams i go faster now :lol:

Code: Select all

::run "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" "<curitem>";

petersboulton
Posts: 157
Joined: 01 Sep 2008 09:54

Re: Script on toolbar button to launch file into Excel problem

Post by petersboulton »

Stefan wrote:This quoting tricked me always too, but it seams i go faster now :lol:

Code: Select all

::run "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" "<curitem>";
Thanks Stefan, but your modification gives me a scripting error message box:

"The system cannot find the file specified.
run "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" "G:\TEMP\prodsNew.tab"

zerO's proposal, (OpenWith "C:\Program Files\Microsoft Office\Office12\EXCEL.EXE";) works, many thanks!

However, is the problem with ::run "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" "<curitem>"; a bug?

Pete

zer0
Posts: 2676
Joined: 19 Jan 2009 20:11

Re: Script on toolbar button to launch file into Excel problem

Post by zer0 »

petersboulton wrote:
Stefan wrote:This quoting tricked me always too, but it seams i go faster now :lol:

Code: Select all

::run "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" "<curitem>";
Thanks Stefan, but your modification gives me a scripting error message box:

"The system cannot find the file specified.
run "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" "G:\TEMP\prodsNew.tab"

zerO's proposal, (OpenWith "C:\Program Files\Microsoft Office\Office12\EXCEL.EXE";) works, many thanks!

However, is the problem with ::run "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" "<curitem>"; a bug?

Pete
You're welcome, I'm glad you're up and running with your TB :)

I believe the reason why Stefan's script doesn't work is because he used Office11 in the address of Excel's location, which suggests that he's on Office 2003. Your original script has Office12 so you're using Office 2007, correct?
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Script on toolbar button to launch file into Excel problem

Post by jacky »

petersboulton wrote:However, is the problem with ::run "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" "<curitem>"; a bug?
Probably not, as I believe it should be more like this:

Code: Select all

::run """C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE"" ""<curitem>""";
And FYI, your first try didn't work because you single-quoted the argument, and variables aren't resolved in single-quoted strings. So, indeed, XY was sending along a literal <curitem> as parameter to Excel.
Proud XYplorer Fanatic

petersboulton
Posts: 157
Joined: 01 Sep 2008 09:54

Re: Script on toolbar button to launch file into Excel problem

Post by petersboulton »

OP here. Sorry, I did not notice the 'Office11' bit. I am Office12 (2007) so I can understand why I got the error message! :roll: Sorry about that!

Jacky's script works fine, thanks and I'm sorry I mentioned the B(ug) word. I should know better!

The user defined buttons are another great new feature!

Thanks to all for your help. Appreciated.

Pete

Post Reply