Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8294719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:19:19+00:00 2026-06-08T14:19:19+00:00

I will like to create visual studio macros in c#. What am I doing

  • 0

I will like to create visual studio macros in c#. What am I doing now is to create the macros in a class library then execute them from vba. the problem is that I cannot debug the macros because I cannot step into the dll from vba.

Anyways I will like to create the macro in a console application for debuging purpuses. Once I know it works I will just place it on the dll.

Here is my code so far:

class Program
{        
    static void Main( string[] args )
    {            
        EnvDTE80.DTE2 MyDte;
        MyDte = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject( "VisualStudio.DTE.10.0" );
        Console.WriteLine( "The Edition is " + MyDte.Edition );

        Console.ReadLine( );

        Console.Write( MyDte.ActiveDocument.Selection.Text );


        Console.Read( );                                                                           
    }

}

note I added the references that visual studio macros uses:

enter image description here


Edit

Maybe I get an exception because I am trying to modify the document that I am currently debugging. If I could manage to get the dte of a second instance of visual studio document ( document that is not being debuged ) I might be able to solve this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:19:20+00:00Added an answer on June 8, 2026 at 2:19 pm

    This answer should enable you to create a visual studio macro in any programing language in any type of application. I am creating one in a wpf application using the ide class located on the link:

    https://stackoverflow.com/a/11713078/637142

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a Visual Studio like plugin for Eclipse that will allow me create
I'd like to create an extension to Visual Studio that will allow someone to
Hi I would like to create a Visual Studio snippet that I can have
I'm using visual studio 2010, I want to create several OvalShapes from VB PowerPacks
I would like to use Visual Studio 2010 to create a C++ application that
I want to create in C# Visual Studio 2010 my user control from standard
We're using Perforce and Visual Studio. Whenever we create a branch, some projects will
I need to create a lot of macros in visual studio the probelem is
I like to create a specific filename for a file that will be created
I would like to create a regular expression that will replace a normal space

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.