# Question about macros in vs .net 2k3

This topic is 4805 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I recorded a macro to draw comment bars... you know, these things:
//---------------------------------------------------
//  Comment here
//---------------------------------------------------

It works, and I figured out how to bind it to a key like Alt+3. However, when I try to undo it, it "undoes" it part by part (as if I had typed it) instead of erasing the whole comment bar at once. Does anyone know any workaround for this? I tried consolidating some of the lines of the macro code... For example: DTE.ActiveDocument.Selection.Text = "//--------------------" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text = "//" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text = "//--------------------" I tried changing this to: DTE.ActiveDocument.Selection.Text = "//--------------------" + chr(13) + "//" + chr(13) + "//------------------" However, it still treats it as separate elements :( Well, it's not so bad but it'd be nice if it worked perfectly... Thanks! roos

##### Share on other sites
I don't know, but that is such an awesome idea that I'm gonna implement it myself. I'll let ya know if I find a solution (although I think it's likely it can't be avoided).

##### Share on other sites
OMG, macros rock so much. There are a billion things I can do with this; I only wish I found out about these things earlier. Kudos man.

##### Share on other sites

Btw if anyone else is curious here's a 30 second guide to how to use macros in vs .net 2k3...

1. Press CTRL+Shift+R to begin recording the macro. (Can also be accessed via Tools->Macros->Start recording or something like that)

2. Type out the following:

//-------------------------------------------------------// Text//-------------------------------------------------------

3. Highlight the word "Text". The reason for doing this is so that, every time you place a comment bar, the text is highlighted so you can type in the actual text and it will replace the word "Text"

4. Stop recording the macro by pressing CTRL+Shift+R again.

5. If you want to preview the effect of the macro before saving it, press CTRL+Shift+P to execute the macro.

6. Go to Tools->Macros->Save Temporary Macro, and type in the name for your macro. (e.g. CommentBarMaker).

7. Now your macro is saved. Go to Tools->Options->Environment->General->Keyboard. Here, you'll see a list of commands. Find the one called something like Macros.MyMacros.RecordingModule.CommentBarMaker, and assign it whatever key you want.

That's it more or less... I might have glossed over something but it should be enough to figure it out :)

roos

1. 1
2. 2
frob
16
3. 3
4. 4
5. 5
JoeJ
10

• 20
• 13
• 14
• 76
• 22
• ### Forum Statistics

• Total Topics
632139
• Total Posts
3004369

×