Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Visual Studio event macro to repair messed up DreamWeaver comments

0.00/5 (No votes)
6 Dec 2004 1  
A macro for Visual Studio 7 to repair DreamWeaver comments when a file is saved.

Introduction

If you work with files in both Visual Studio and DreamWeaver, then you may have run into a VS anomaly that will quickly drive you to the nut house. DreamWeaver templates work by using special HTML comments carefully placed in the source file. These comments are used to perform updates to the file when a template is re-applied. Move or modify these comments just a little and DreamWeaver can no longer update the source file. In the worse case, it can't even display the file properly within its editor!

The problem happens when you edit a file containing these special comments using Visual Studio 2002 and 2003. The great minds at Microsoft decided these comments were not correct, so the auto-formatter moves them around willy-nilly. My research has found that Microsoft knows about the problem and it will be fixed in Visual Studio 2005, so they say. However, I can't wait. This is driving me nuts right now, having to cut and paste all the comments back into their proper places before I edit the file in DreamWeaver.

Solution

What I did was write a macro that will search for these comments and move them back to where they belong when a source file is saved. I used the DocumentSaved event of the VS environment to do this. I would have preferred a DocumentSaving event so I could modify the document before being saved. This would have prevented my macro from causing a save-modify-save every time, but such is life. We can't have everything we want.

To install the macro, download the zip and copy the macro's contents into a macro file. The code is commented, so you'll have to glean the details directly from it if you are interested.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here