views:

32

answers:

1

I am looking at this piece of code that I got from here because I would like to use it. The issue is, I have used 2003 to create the "test.xls" file but when I run this code it opens in 2007. Is there any way to force this to open in a specific Excel version rather than the default?

GoSub, GuiOpen
pweb := COM_AtlAxCreateControl(WinExist(), A_Temp . "\test.xls")
pxlb := COM_Invoke(pweb, "Document")      ; Excel Workbook
pxls := COM_Invoke(pxlb, "Worksheets", 1)   ; Excel Worksheet
Return

GuiOpen:
Gui, +Resize +LastFound
Gui, Show, w800 h600 Center, Excel
COM_AtlAxWinInit()
Return
GuiClose:
Gui, Destroy
COM_Invoke(pxlb, "Save")
COM_Release(pxls)
COM_Release(pxlb)
COM_Release(pweb)
COM_AtlAxWinTerm()
ExitApp
A: 

This has to do with the way that file is associated on windows...try this on an open folder:

Tools > Folder Options > FileTypes

Look for the xls file and change which program opens it. If you dont find it simply add it and change its options accordingly.

RaptorX
The extension is assigned correctly, if I double click the file it opens with 2003 and when I double click xlsx files they open with 2007. It's when I try to open it programmatically that causes the issue. It's not only with opening files either, if I want to create an Excel.Application object it will always create a 2007, I can't get it to open an Excel.Application object in 2003.
Geoff