Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-10-2010, 02:52 PM
beav_35 beav_35 is offline VB code from one document runs on other open documents Windows 7 VB code from one document runs on other open documents Office 2007
Novice
VB code from one document runs on other open documents
 
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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I add a peace of code to MS document amlife Word VBA 0 03-03-2010 03:35 PM
Can't open documents directly from a shared drive MikeJedi Word 0 12-08-2009 12:04 PM
VB code from one document runs on other open documents Excel Files Will Not Open From Documents Normally tremaine Excel 1 06-17-2009 08:05 AM
Some Word documents open slower than others Mosaic Word 1 09-21-2007 02:53 PM
VB code from one document runs on other open documents Documents Take 5 Minutes To Open Farrar Word 1 07-23-2007 02:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft