Can you save an Excel spreadsheet opened within Progress as a .csv?

rip73

New Member
In reading a few of the posts I think I'm getting the sense that Progress may not allow this. Is that a correct assumption?

If Progress is able to open an Excel file and later save it as a .csv how is that done? I am not able to have it save as a .csv. I get the following error message.

"Invalid component handle referenced while processing method/statement: SaveAs. 5884"

I do not release any handles until after the SaveAs statement so I am not sure why this message is happening.

Here is the code segment

assign xSaveAsName = "c:testcsv.csv".

CREATE "Excel.Application" chExcel.

chExcel:Visible=false.
chExcel:Workbooks:OPEN(xfile-name:screen-value).

/* Select a worksheet */
chWorkSheet = chExcel:Sheets:Item(2).

chExcel:Worksheets(2):Activate.

/* Save a new workbook as .csv */
chWorkbook:SaveAs(xSaveAsName,6,,,,,,,TRUE).

/*** Release All Com-handles ***/

release object chExcel no-error.
release object chWorkbook no-error.
release object chWorksheet no-error.


Also if you know of any good reference material about using Excel within Progress that would be appreciated as well.
 

GregTomkins

Active Member
I don't think Progress knows or cares about the names of purpose of specific Excel functions. I am pretty sure that if Excel created a new method called "ProgressIsEvil", Progress would happily try to call it and it would work provided your version of Excel recognizes it.

I think your problem is that "chWorkbook" is never set to a valid value.
 
hi Rip73,

change following lines:
- assign xSaveAsName = "c:testcsv.csv". --> "c:\testcsv.csv".
- chWorkbook:SaveAs(xSaveAsName,6,,,,,,,TRUE) --> chExcel:ActiveSheet:SaveAs(xSaveAsName,6,,,,,,,TRUE).


and don't forget to close excel.

add following line:

chWorkBook:close.
chExcel:close.
 

D.Cook

Member
I find the Excel VBA Reference help file installed with Excel to be pretty handy. It lists all the functions you can access via the COM interface. Obviously the format is in VBA, but you can translate to ABL quite easily.

It's usually located in a location like:
C:\Program Files\Microsoft Office\Office12\1033\VBAXL10.CHM
 
Top