Stop Module, Forms opening

J

John

Hi,

How (If possible) can i stop XL opening all the Module windows when i either
open a Workbook or activate it please?

Thanks
John
 
S

Simon Lloyd

John;385585 said:
Hi,

How (If possible) can i stop XL opening all the Module windows when i
either
open a Workbook or activate it please?

Thanks
John
When you say all the module windows on opening do you mean the VBA
module windows when you open the VBE or do you mean the worksheets?


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
 
S

Simon Lloyd

Simon said:
When you say all the module windows on opening do you mean the VBA
module windows when you open the VBE or do you mean the worksheets?I am assuming you want the VBA module windows closed, firstly in the VBE
you must go to TOOLS>REFERENCES and click the check box next to
-Microsoft Visual Basic for Applications Extensibility 5.3- without this
it will always fail at the project commands, next add this to the
thisworkbook module:

Code:
--------------------
Private Sub Workbook_Open()
Dim WB As Workbook
Dim VBP As VBProject, PrWin As VBIDE.Window
Dim i As Integer
Set VBP = ThisWorkbook.VBProject
Set wbActive = ActiveWorkbook
'Close all code windows
For Each oWin In VBP.VBE.Windows
If InStr(PrWin.Caption, "(") > 0 Then PrWin.Close
Next PrWin
End Sub
--------------------
now ehn your workbook opens it will close all vbe module windows.


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
 
J

John

Hi Simon,

Thanks for the solution. It works great. I guess i should have been a
little more clearer. I'm running a loop in a procedure to open a number of
workbooks. What i would like is each time a Workbook is opened none of the
VBA modules forms open. Is this possible to code this in my loop please?

Thanks
John
 
S

Simon Lloyd

In that case john the code would need to reside in your PERSONAL.xls
this base workbook can house the code that you wish to run on each
active wrokbook.
John;385730 said:
Hi Simon,

Thanks for the solution. It works great. I guess i should have been a
little more clearer. I'm running a loop in a procedure to open a number
of
workbooks. What i would like is each time a Workbook is opened none of
the
VBA modules forms open. Is this possible to code this in my loop
please?

Thanks
John


worksheets?I am assuming you want the VBA module windows closed, firstly
in the VBE
Office Discussion' (http://www.thecodecage.com))
Lloyd' (http://www.thecodecage.com/forumz/member.php?userid=1)


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
 
Top