/* RxXL_Automation_013.rex */ /* The purpose of this application is to demonstrate the use of ooRexx ActiveX/OLE to automate the opening of the Excel Workbook created with RxXL_Automation_012.rex. In this demonstration we will insert a new row between the existing rows 1 & 2 We will also insert a column between the existing columns B & C */ --Clear the screen call SysCls -- Create the Excel object xlobj = .OleObject~New('Excel.Application') /* Turn the visible attribute on so that we can see what is happening In a production application, this can be set to false */ xlobj~Visible = .true --Open the existing workbook infile = '.\RxXL_Automation_012.xls' xlobj~WorkBooks~Open(infile) -- Insert a row between the existing rows 1 & 2 insert_before = 2 xlobj~Rows(insert_before':'insert_before)~Insert -- Insert a column between the existing columns B & C insert_before = 'C' xlobj~Columns(insert_before':'insert_before)~Insert /* Now that we have finished creating our workbook, lets give it a name and save it we'll save it in the default Excel folder (which will probably be My Documents' NOT the folder that this application is running in - you can provide any path you'd like */ outfile = '.\RxXL_Automation_013.xls' /* We may want to run this several times and Excel will prompt us about replacing an existing file. Since this conflicts with "automation" we'll need to turn off the Excel warnings */ xlobj~DisplayAlerts = .false --Save the file xlobj~ActiveSheet~SaveAs(outfile) --Close the Workbook xlobj~WorkBooks(1)~Close(SaveAll) --Quit Excel xlobj~Quit say 'Examine the column formulas now and you will see that the inserted row is included' say 'Examine the row formulas now and you will see that the inserted column is included' say 'Note that the value of the COUNTA formula did not change since we inserted an empty cell in the formula range'