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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Freezing Panes in Excel, via OLE2 1

Status
Not open for further replies.

krindler

Programmer
Jul 16, 2002
39
US
Hello.

I have another question regarding inserting data into Excel, via OLE2. I am looking to to Freeze Columns A & B, as well as Rows 1-3.

My first question, is if anyone has an example of the OLE code to Freeze the panes.

My second question is if it is possible to freeze both the Columns and the Rows.

Any help you could give me would be much appreciated.

Thanks in Advance,
Kelly
 
Usually when I freeze the panes, I set the column widths to automatically adjust. So I thew that code in also.


--------------------------------------------------
-------- Set AutoFit for all columns used --------
--------------------------------------------------
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'A:I' ); --All columns
column := OLE2.GET_OBJ_PROPERTY(worksheet, 'Columns', args);
entirecolumn := OLE2.GET_OBJ_PROPERTY(column, 'EntireColumn');
OLE2.DESTROY_ARGLIST(args);

OLE2.SET_PROPERTY(EntireColumn, 'AutoFit', TRUE);
OLE2.RELEASE_OBJ(EntireColumn);
OLE2.RELEASE_OBJ(column);


----------------------------------------
-------- Freeze the panes at C4 --------
----------------------------------------
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 4 );
OLE2.ADD_ARG(args, 'C');
cell := OLE2.GET_OBJ_PROPERTY(worksheet, 'Cells', args);
OLE2.SET_PROPERTY(cell, 'Select', TRUE);
OLE2.DESTROY_ARGLIST(args);
OLE2.RELEASE_OBJ(cell);

window := OLE2.GET_OBJ_PROPERTY(Application, 'ActiveWindow');
OLE2.SET_PROPERTY(window, 'FreezePanes', TRUE);
OLE2.RELEASE_OBJ(window );



If you wanted to freeze only columns then you need to use a cell that is to the right of the columns you want to freeze and in row 1 of that column. For example, to freeze columns A:E, you would need to use cell F1.

If you wanted to freeze only rows then you need to use a cell that is below the row you want to freeze and in column A of that row. For example, to freeze rows 1:4 you would use cell A5.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top