Problem with Excel OLE

In the archived forums there is a great example of controlling excel through ole automation.

I have used the sample program from time to time with out a problem, however I am trying to duplicate a VBA macro that formats a header row nicely. I have most of it working except "AutoFit" and "FreezePanes". AutoFit is more important to me than FreezePanes.

Here is the VB code:

 Rows("1:1").Select
 With Selection.Interior
         .ColorIndex = 37
         .Pattern = xlSolid
 End With
 Selection.Font.Bold = True
 Selection.AutoFilter
 Rows("2:2").Select
 ActiveWindow.FreezePanes = True
 Cells.Select
 Cells.EntireColumn.AutoFit
 Range("A1").Select

Here is the reevant parts of the COBOL code:

INQUIRE EX-WORKBOOK @Worksheets::Item(1) IN EX-WORKSHEET.

INQUIRE EX-WORKSHEET @Range("A3:O3") IN EX-RANGE.
MODIFY EX-RANGE @Font::Bold = 1.
MODIFY EX-RANGE @Interior::ColorIndex = 37.
MODIFY EX-RANGE @Interior::Pattern = @xlSolid.
MODIFY EX-RANGE @AutoFilter = 1.
* MODIFY EX-RANGE @AutoFit.
* MODIFY EX-WORKSHEET @FreezePanes = 1.

DESTROY EX-RANGE.

 It works with AutoFit and FreezePanes remarked out.

Any ideas?

Tags: