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.