ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Freeze pane Prob & Activewindow (https://www.excelbanter.com/excel-programming/321191-freeze-pane-prob-activewindow.html)

kdw

Freeze pane Prob & Activewindow
 
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


kdw

Freeze pane Prob & Activewindow
 
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




Tom Ogilvy

Freeze pane Prob & Activewindow
 
Just a heads up. Something doesn't appear to be right Gordon. A workbook
doesn't have an activewindow property. You haven't put periods infront of
ActiveWindow so there is no reason for the With statement. The code
should run fine as written, but again, the With statement is superfluous as
written. I suspect there is a typo here or an omitted statement - just
thought I would bring it to your attention if such is the case.

--
Regards,
Tom Ogilvy

"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
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





Gord Dibben

Freeze pane Prob & Activewindow
 
Thanks Tom

I had the code kicking around without the With ActiveWorkbook and End With
lines.

I mistakenly thought that adding those lines would point the OP's code to the
ActiveWorkbook instead of the original workbook.

They are superfluous as you say and Sub certainly wouldn't work without the
periods if the workbook did have an activewindow property.

I'm going back to the ToolsOptions section now<g

Gord

On Wed, 19 Jan 2005 18:23:19 -0500, "Tom Ogilvy" wrote:

Just a heads up. Something doesn't appear to be right Gordon. A workbook
doesn't have an activewindow property. You haven't put periods infront of
ActiveWindow so there is no reason for the With statement. The code
should run fine as written, but again, the With statement is superfluous as
written. I suspect there is a typo here or an omitted statement - just
thought I would bring it to your attention if such is the case.




All times are GMT +1. The time now is 11:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com