HOWTO: How to Freeze Panes

Reference: Q0047

Article last modified on 15-Feb-2008


The information in this article applies to:

  • XLL+ for Visual Studio .NET - 3, 4.1, 4.2, 4.3.1, 5.0
  • XLL+ for Visual Studio 6 - 3, 4.1, 4.2, 4.3.1, 5.0
  • XLL+ for Visual Studio 2005 - 5.0

How to Freeze Panes

Issue

How do I freeze the panes of a worksheet, like the Window/Freeze Panes command in Excel?

Solution

To freeze the panes of the active worksheet, use code like the following:

static int xlCommand  = 0x8000;
static int xlcFreezePanes = (135 | xlCommand);

int col_split = 2;
int row_split = 3;
int rc = CXllApp::Excel(xlcFreezePanes, 3, &CXlOper(TRUE), 
    &CXlOper((double)col_split), &CXlOper((double)row_split));

To remove the split (like the Window/Remove Split command):

int rc = CXllApp::Excel(xlcFreezePanes, 1, &CXlOper(FALSE));