Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progress/Excel

Status
Not open for further replies.

raymoose

IS-IT--Management
Feb 9, 2004
2
US
I have created a csv file in progress and would like to open excel using the created csv file. I have tried using the commands below and I am not having much luck, any suggestions.

DEF VAR excel AS COM-HANDLE.
DEF VAR workbook AS COM-HANDLE.
DEF VAR worksheet1 AS COM-HANDLE.
DEF VAR worksheet2 AS COM-HANDLE.
DEF VAR range AS COM-HANDLE.

CREATE "Excel.Application" excel.

excel:VISIBLE=FALSE.

excel:workbooks:ADD.
/* excel:Workbooks:Open FileName:="F:\Temp\MRT-GM2.csv". This is the command I can not get to work. */

excel:VISIBLE=TRUE.
RELEASE OBJECT excel NO-ERROR.
RELEASE OBJECT workbook NO-ERROR.
RELEASE OBJECT worksheet1 NO-ERROR.
RELEASE OBJECT worksheet2 NO-ERROR.
RELEASE OBJECT range NO-ERROR.
 
raymoose,

Don't bother with
Code:
excel:workbooks:ADD.

The correct syntax for opening the file with your set of com-handle variables is:
Code:
    ASSIGN workbook = excel:Workbooks:Open("F:\Temp\MRT-GM2.csv").
And to select the worksheet after opening (at least I think so ... please don't shoot me if I'm wrong):
Code:
    ASSIGN worksheet1 = excel:Sheets:Item(1).
And finally ... release your com-handles in reverse order.
 
This worked great. I appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top