views:

349

answers:

1

I have a situation where I want to run a Visual Studio macro that has the user type something in an InputBox, then inserts a snippet and includes that text somewhere in it. Unfortunately, I can't figure out how to insert the snippet from macro code. It seems like it'd be something like

DTE.ExecuteCommand("Edit.InvokeSnippetFromShortcut")

or

DTE.ExecuteCommand("Edit.InvokeSnippetFromShortcut", "theSnippetName")

but those don't work. Any ideas?

A: 

You need to decide where this code should be selected. To insert text in current text selection you need to use the following code:

Dim textSelection As EnvDTE.TextSelection
textSelection = DTE.ActiveWindow.Selection          
textSelection.Insert(MyTextVarHere)
Yaroslav Yakovlev
I want to insert a *snippet*. Not just some text. *Snippet* has a specific meaning in Visual Studio.
Kyralessa