Home > Back-end >  Through the Delphi freeze panes on the excel for operation
Through the Delphi freeze panes on the excel for operation

Time:11-08

Excuse me to freeze panes on the excel for operation exactly how to get? I use the following code, running to the "excel. ActiveWindow. FreezePanes:=true" this way, there is always "EOleSysError with message 'server unexpected situation,'" error,

Procedure TForm1. Button4Click (Sender: TObject);
Var Excel, xlbook xlsheet: OleVariant;
The begin
The try of Excel:=CreateOLEObject (' Excel. Application);
Except,
Application. MessageBox (' excel is not installed, the 'message', MB_OK + MB_ICONASTERISK + + MB_APPLMODAL MB_DEFBUTTON1);
The Exit;
The end;
Try
Xlbook:=Excel WorkBooks. Open (extractfilepath (application. ExeName) + 'query table. XLSX');

Excel. WorkSheets [' Sheet1]. Activate;
Excel. ActiveWindow. FreezePanes:=false;

Excel. ActiveWindow. SplitColumn:=2;
Excel. ActiveWindow. SplitRow:=1;

XlBook. Worksheets [' Sheet1] cells (2, 1]. Activate;
Try
Excel. ActiveWindow. FreezePanes:=true;
Except,
The end;

. Excel worksheets [' Sheet1] cells (2, 1]. Activate;
Try
Excel. ActiveWindow. FreezePanes:=true;
Except,
The end;

Xlbook. ActiveSheet. Range [' A2 ']. Select;
Try
Excel. ActiveWindow. FreezePanes:=True;
Except,

The end;

Excel. ActiveSheet. Range [' A2 ']. Select;
Try
Excel. ActiveWindow. FreezePanes:=True;
Except,
The end;

The finally
Excel. DisplayAlerts:=False;
Excel. ActiveWorkBook. Save;
. Excel WorkBooks. Close;
Excel. Quit;
The end;
The end;



I try to run directly in excel macro is below normal,
{Sub Macro1 ()
Range (" A2 "). Select
ActiveWindow. FreezePanes=True
End Sub}

(Delphi 7) excuse me, how to solve?

CodePudding user response:

No one knows the problem?
  • Related