View Single Post
 
Old 11-10-2010, 02:52 PM
beav_35 beav_35 is offline Windows 7 Office 2007
Novice
 
Join Date: Nov 2010
Posts: 1
beav_35 is on a distinguished road
Default VB code from one document runs on other open documents

When I open two documents one with VB code and the other with none the macros in the first document seem to apply to both documents. In fact if I have multiple documents with VB code open the code in each document applies to every other document that is open.
Has anyone else seen this bug before and know any solutions or workarounds?

This is the code that I used to test:

Dim WithEvents wdapp As Application
Private Sub Document_Open()
Set wdapp = Application
End Sub

Private Sub Document_New()
Set wdapp = Application
End Sub
Private Sub wdapp_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
MsgBox ("This document has macros")
End Sub
Private Sub Document_Close()
Set wdapp = Nothing
End Sub
Reply With Quote