philz
Joined: 05 Jun 2007 Posts: 89 Location: USA
|
Posted: Mon Aug 11, 2008 2:57 am Post subject: Converting XLSX to CSV using COM |
|
|
I'm Using the COM library.
It's Quite cool, the only wish I could have for it is to not have to do those nested com_invoke functions for objects. I've only tested it using Excel 2007, although the object library is similar to previous versions.
Three Questions I have
Is it possible to do something like this COM_invoke(excel, "worksheets(2).select")
How can I do error handling (click cancel on a prompt to overwrite msgbox and you'll know what I mean
I keep getting orphaned Excel Processes. how can i kill those without using process, close, excel.exe
Here is the code
| Code: |
COM_CoInitialize()
loop, f:\documents\test\*.xlsx
{
regexmatch(a_loopfilelongpath, ".*\.", savename)
savename := savename "csv"
excel := com_createobject("excel.application")
com_invoke(com_invoke(excel,"Workbooks"),"open",a_loopfilelongpath)
com_invoke(com_invoke(excel, "activeworkbook"),"Saveas", savename, 6) ;saves as a csv
com_invoke(com_invoke(excel, "activeworkbook"), "Close", False)
com_invoke(excel,"quit")
}
|
Any help is much appreciated |
|