Executing a macro/script whenevera document is saved

Joined
Oct 27, 2008
Messages
1
Reaction score
0
Hi,

I am trying to figure out how to run a macro/script whenever a file is saved in Visual Studio. I saw an earlier thread here on the same topic:

https://www.pcreview.co.uk/forums/thread-3449080.php

and using its advice, I went and added a function to the EnvironmentEvents module in MyMacros. Now if I open the Macros IDE and use the class view to navigate to "MyMacros > {} MyMacros > EnvironmentEvents", I have the following text:

Code:
    Option Strict Off
    Option Explicit Off
    Imports System
    Imports EnvDTE
    Imports EnvDTE80
    Imports System.Diagnostics
    
    Public Module EnvironmentEvents
    	 Public WithEvents DocumentEvents As EnvDTE.DocumentEvents
    
    	Public Sub DocumentEvents_DocumentSaved(ByVal Document As EnvDTE.Document) Handles DocumentEvents.DocumentSaved
    		MsgBox("test")
    	End Sub
    
    	Public Sub DocumentEvents_DocumentClosing(ByVal Document As EnvDTE.Document) Handles DocumentEvents.DocumentClosing
    		MsgBox("test")
    	End Sub
    
    End Module

However, even after doing this, I do not get any notification message box when I save/close a document in Visual Studio. I restarted Visual studio just to make sure.

My setup:

Microsoft Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727


I'd greatly appreciate finding out what I am doing wrong.

Thanks,
Srinath
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top