I have a VS2010 macro that inserts bolierplate header text at top of each class. Running the macro inserts module name, developer, description, etc. as expected.

Instead of typing the module name, i would like to insert the name into the text. How do I get the class (or form name) name when I run the macro in the selected code page?

I have looked at reflection, but not sure how to get the form/class name my cursor is on for the macro execution

share|improve this question
Out of curiosity: why do you need all this crap like developer, module name, etc? – Anton Gogolev Apr 18 '11 at 14:25
I don't know if reflection will work for you since there can technically be more than one class definition in a file (including nested or private classes). So if you found a way to say "the class defined in this file", you could get more than one result. – Justin Morgan Apr 18 '11 at 14:28
Dim projectItem As ProjectItem projectItem = DTE.ActiveDocument.ProjectItem Dim cName As String = projectItem.Name.ToString – ncsol Apr 18 '11 at 15:36
sorry about that. it is needed by corporate rules, not mine and as you stated reflection doesn't work, but using the macro dte does. – ncsol Apr 18 '11 at 15:38
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.