View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default 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