FreezePanes from VBA?

G

G Lykos

Greetings! Not understanding what I'm seeing. I'm creating an Excel
workbook from MS Project VBA, then formatting a worksheet in it and
exporting data to it. I want to freeze the pane, and captured the steps
below in a macro from within Excel, then inserted it into the Project sub.

Problem: when the MS Project sub executes, the Select below executes and
the worksheet responds, and the True line below executes but the worksheet
doesn't respond.

'Freeze
Range("F5").Select
ActiveWindow.FreezePanes = True

Any ideas why this doesn't work?

Thanks,
George
 
W

William

Hi

Try this

ActiveWindow.FreezePanes = False
Range("F5").Select
ActiveWindow.FreezePanes = True
--

Regards

William

XL2003

(e-mail address removed)


| Greetings! Not understanding what I'm seeing. I'm creating an Excel
| workbook from MS Project VBA, then formatting a worksheet in it and
| exporting data to it. I want to freeze the pane, and captured the steps
| below in a macro from within Excel, then inserted it into the Project sub.
|
| Problem: when the MS Project sub executes, the Select below executes and
| the worksheet responds, and the True line below executes but the worksheet
| doesn't respond.
|
| 'Freeze
| Range("F5").Select
| ActiveWindow.FreezePanes = True
|
| Any ideas why this doesn't work?
|
| Thanks,
| George
|
|
 
G

Guest

I was just logging in to ask a question about FreezePanes... will just append
it here.

I know that that's the way it's designed and written, etc...

But, logically, is there an explanation that someone can give to me why
FreezPanes is a property of the Window object, and not of the Worksheet
object?

Maybe I'm just missing it.

Thanks.
 
N

NickHK

Mark,
If you make another window (Windows>New) then arrange them so you see both
simultaneously.
Now freeze the panes somewhere on the active window.
You will see the other window is not affected.
Hence it is not a Worksheet property, but a property of the Window.
As you normally only have a single window/workbook, you tend not to notice
this behaviour.

NickHK
 
G

Guest

I hear what you're saying, but I don't think that's the end of the story.

Think of it this way... if you have one workbook, with 10 sheets, and you
have the FreezePanes set on sheet 2, but not any other...

if you click any sheet but sheet 2, the FreezePanes is false, but if you
click on sheet 2, FreezePanes is true.

All in ONE window.

Hence, it is (or should be) also a property of the worksheet.
 
G

G Lykos

Nick, I was expecting that the pane would be frozen, same as if I did the
same thing by hand. However, I step through the execution, and the cell is
selected, per below, but then the VBA freezepanes method has no effect.
This from VBA running in MS Project.

George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top