VBA Code Windows

B

BillCPA

Is there any way to set the parameters (or change the default parameters) for
the various VBA windows - code, properties, etc. - to control where they
display on the screen and their size?
 
C

Chip Pearson

First, set a reference (VBA Editor Tools menu, References) to the
"Microsoft Visual Basic For Applications Extensibility 5.3"
library. Then you can use the Window object to control the
Window properties of a specified CodePane.


With
ThisWorkbook.VBProject.VBComponents("Module1").CodeModule.CodePane.Window
Debug.Print .Top, .Left, .Height, .Width
End With



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
B

BillCPA

The solution below has worked for the code windows for VBA worksheets and
modules. It also works for the form 'code' window, but does not work for the
form window - the window in which the form itself is displayed.

Here is what I am using:

For Each cmpComponent In cmpComponents
cmpName = ThisWorkbook.VBProject.VBComponents(cmpComponent.Name).Name

ThisWorkbook.VBProject.VBComponents(cmpName).CodeModule.CodePane.Window.Top =
12
..
..
..
next cmpComponent

Is there something that needs to be specified (seems like you might use
'FormPane' instead of 'CodePane', but of course you don't) to get it to work
for the form?

I've always wondered if a response to an old question was posted, it would
ever get noticed. I guess I'll find out. If I don't hear something in a
couple of days, I'll try you on your web site.
 
Top