ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Stop Module, Forms opening (https://www.excelbanter.com/excel-programming/430006-stop-module-forms-opening.html)

John

Stop Module, Forms opening
 
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

Simon Lloyd[_1156_]

Stop Module, Forms opening
 

John;385585 Wrote:
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)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=107828


Simon Lloyd[_1157_]

Stop Module, Forms opening
 

Simon Lloyd;385589 Wrote:
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 TOOLSREFERENCES 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)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=107828


John

Stop Module, Forms opening
 
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

"Simon Lloyd" wrote:


Simon Lloyd;385589 Wrote:
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 TOOLSREFERENCES 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)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=107828



Simon Lloyd[_1158_]

Stop Module, Forms opening
 

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 Wrote:
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

"Simon Lloyd" wrote:


Simon Lloyd;385589 Wrote:
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 TOOLSREFERENCES 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' ('The Code Cage - Microsoft Office Help - Microsoft

Office Discussion' (http://www.thecodecage.com))

------------------------------------------------------------------------
Simon Lloyd's Profile: 'The Code Cage Forums - View Profile: Simon

Lloyd' (http://www.thecodecage.com/forumz/member.php?userid=1)
View this thread: 'Stop Module, Forms opening - The Code Cage Forums'

(http://www.thecodecage.com/forumz/sh...d.php?t=107828)




--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=107828



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

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