locked
Visio 2007 Development Information RRS feed

  • Question

  • I am having a bit of difficulty finding up to date information on developing a Visio solution using C#.

    Essentially want I want to do is enable a right click capability on a certain shape that can retrieve data from a database, build a drawing based on this data, and display the drawing in a new page. I would like to provide the user with the ability to customize the database connection, etc.

    I have started a Visio Add-in project, but I am not sure how to proceed or if this is the correct approach. Any links with information would be much appreciated.

    Wednesday, April 21, 2010 4:10 PM

Answers

  • Hello Arbitus,

    Basically, I think you could test if it is feasible by UI. If yes, recording a macro would be a good way. Then you could see basic syntax with VBA code. I am not sure I could give you exact information. For this, I think you could add a new item to Context menu. Code like this,

                    Office.CommandBars commandBars = Globals.ThisAddIn.Application.CommandBars as Office.CommandBars;                
                    Office.CommandBar commandBar = commandBars["Drawing Object Selected"];
                    Office.CommandBarButton commandBarButton = (Office.CommandBarButton)commandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true) as Office.CommandBarButton;
                    commandBarButton.Caption = "MYButton";
                    commandBarButton.Tag = "MYButton";
                    commandBarButton.Enabled = true;
                    commandBarButton.Visible = true;
                    commandBarButton.Style = Office.MsoButtonStyle.msoButtonCaption;
                    commandBarButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(commandBarButton_Click);

    For data, here is a MSDN page you could refer to:  http://msdn.microsoft.com/en-us/library/xx069ybh.aspx. Actually, in this forum, there is very few people who frequent this forum with in-depth knowledge about Visio object model. That's because the only thing VSTO does with Visio is provide a template for creating a VSTO add-in. Visio newsgroup would be a better place for this issue: http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.visio.developer&lang=en&cr=US, where there are more Visio specialists, and you would probably get more help.

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Bessie Zhao Thursday, April 29, 2010 7:12 AM
    Friday, April 23, 2010 10:10 AM

All replies

  • I apologize for the vagueness of the previous post. I was throwing up something while frantically searching for answers.

    What I am looking for is to see if there exists the ability to call into my Add-In code from the Actions of a shape master, similar to calling a macro. I would like to do this so that I can assign the formula inside of the master instead of programmatically adding it. Or am I going about this all wrong?

    I do have a design that "works" currently by putting a button in the CommandBars and inspecting the selected shape for custom properties to see if it has the information I need to perform the action. This feels like a kludge, and would prefer the right click method.

    Wednesday, April 21, 2010 6:53 PM
  • Hello Arbitus,

    Basically, I think you could test if it is feasible by UI. If yes, recording a macro would be a good way. Then you could see basic syntax with VBA code. I am not sure I could give you exact information. For this, I think you could add a new item to Context menu. Code like this,

                    Office.CommandBars commandBars = Globals.ThisAddIn.Application.CommandBars as Office.CommandBars;                
                    Office.CommandBar commandBar = commandBars["Drawing Object Selected"];
                    Office.CommandBarButton commandBarButton = (Office.CommandBarButton)commandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true) as Office.CommandBarButton;
                    commandBarButton.Caption = "MYButton";
                    commandBarButton.Tag = "MYButton";
                    commandBarButton.Enabled = true;
                    commandBarButton.Visible = true;
                    commandBarButton.Style = Office.MsoButtonStyle.msoButtonCaption;
                    commandBarButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(commandBarButton_Click);

    For data, here is a MSDN page you could refer to:  http://msdn.microsoft.com/en-us/library/xx069ybh.aspx. Actually, in this forum, there is very few people who frequent this forum with in-depth knowledge about Visio object model. That's because the only thing VSTO does with Visio is provide a template for creating a VSTO add-in. Visio newsgroup would be a better place for this issue: http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.visio.developer&lang=en&cr=US, where there are more Visio specialists, and you would probably get more help.

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Bessie Zhao Thursday, April 29, 2010 7:12 AM
    Friday, April 23, 2010 10:10 AM