This doesn't quite change my issue of the Activewindow property pointing to
the wrong workbook. Perhaps I didn't explain my situation clearly.
My ExportToExcel procedure is written in
VB in a non-Office program. After
exporting the data to Excel, I want to freeze the pane before exiting with
something like:
objXLSheet.Activate
objXLSheet.Range("E3").Select
ActiveWindow.FreezePanes = True
Set objXLSheet = Nothing
Set objXLBook = Nothing
Set objXLApp = Nothing
This works on the first export. The second time I call this procedure no
pane is frozen on the second workbook. If I close the first workbook, the
procedure would fail when I run it again. When I check the Activewindow
property, I found that it still refers to the first workbook no matter what I
do.
Can anyone tell what is my error?
Does not my code above cause objXlSheet to be in the Activewindow?
"Gord Dibben" wrote:
kdw
This might help.
Sub Freeze_Panes()
With ActiveWorkbook
ActiveWindow.SplitRow = 2
ActiveWindow.FreezePanes = True
End With
End Sub
Gord Dibben Excel MVP
On Wed, 19 Jan 2005 12:17:05 -0800, kdw wrote:
I am trying to freeze the pane of a workbook from an Export function in
another program using:
ActiveWindow.FreezePanes = True
This work fine for the first export. Subsequent export would not work. It
would end up freezing the pane if the first workbook, or worse, if the first
workbook was close, an error.
I found that Activewindow still refers to the first workbook, even if I
Activate the sheet/new workbook.
Any ideas? Is there a way to reset the Activewindow property for sure?
Thanks,
kdw