Click here to Skip to main content
15,887,337 members
Articles / Web Development / HTML

Visual Studio event macro to repair messed up DreamWeaver comments

Rate me:
Please Sign up or sign in to vote.
3.68/5 (6 votes)
6 Dec 2004CPOL1 min read 45.5K   152   8   8
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Charles works at PC Tools in Boulder, CO as a "do everything" developer. He's worked with Windows development for over 10 years and web development for over 5.

Comments and Discussions

 
QuestionSame problems? Pin
javodv18-Jul-05 9:35
javodv18-Jul-05 9:35 
AnswerRe: Same problems? Pin
edonistart18-Jul-05 20:26
edonistart18-Jul-05 20:26 
GeneralProblem installing... Pin
edonistart5-Jul-05 8:03
edonistart5-Jul-05 8:03 
AnswerUpdated the Download Pin
Charles Windhausen16-Sep-05 8:12
Charles Windhausen16-Sep-05 8:12 
GeneralWorks perfectly!!!! Pin
edonistart17-Sep-05 0:43
edonistart17-Sep-05 0:43 
GeneralRe: Works perfectly!!!! Pin
carzel4-Nov-05 8:36
carzel4-Nov-05 8:36 
GeneralThank you so much!!! Pin
edonistart5-Jul-05 7:11
edonistart5-Jul-05 7:11 
GeneralThanks Pin
kdubious24-Feb-05 11:47
kdubious24-Feb-05 11:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.