none
Embedding Visio Control in Excel Document VSTO RRS feed

  • Question

  • While attempting to use the Visio Control in a Document Task Pane, I get several issues and the control does not work. The control works fine in a regular form and even a UserControl (which I tried to embed to later use from Excel VSTO.

    This is what happens while trying to use in Excel Document VSTO's Document Task Pane

    1. When dropping the control on the Document Task Pane, I get  automatically 2 extra references to atdole added. One was already there but the other two are added when dropping the visio control.  The existing one points to: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\stdole.dll , the second and the third point to: C:\WINDOWS\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll but they both get a GUID for the Identity property.  I must remove both new ones or the project would not build.

    2. When I remove both additional references to stdole, the project builds but I will get a run time error at this designer inserted line: ((System.ComponentModel.ISupportInitialize)(this.axDrawingControl1)).EndInit();

    The error's stack trace is this: 

       at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
       at System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
       at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
       at System.Windows.Forms.AxHost.CreateInstance()
       at System.Windows.Forms.AxHost.GetOcxCreate()
       at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
       at System.Windows.Forms.AxHost.CreateHandle()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.AxHost.EndInit()
       at R2T.Workflow.InitializeComponent() in C:\Users\ramon.aldana\Source\R2T\R2T\Workflow.Designer.cs:line 196
       at R2T.Workflow..ctor() in C:\Users\ramon.aldana\Source\R2T\R2T\Workflow.cs:line 13
       at R2T.ThisWorkbook.ThisWorkbook_Startup(Object sender, EventArgs e) in C:\Users\ramon.aldana\Source\R2T\R2T\ThisWorkbook.cs:line 15
       at Microsoft.Office.Tools.Excel.WorkbookImpl.OnStartup()
       at Microsoft.Office.Tools.Excel.WorkbookImpl.WorkbookExtensionImpl.Microsoft.Office.Tools.EntryPoint.OnStartup()
       at Microsoft.Office.Tools.Excel.WorkbookBase.OnStartup()
       at R2T.ThisWorkbook.FinishInitialization() in C:\Users\ramon.aldana\Source\R2T\R2T\ThisWorkbook.Designer.cs:line 57
       at Microsoft.Office.Tools.Excel.WorkbookBase.Microsoft.Office.Tools.EntryPoint.FinishInitialization()
       at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.ExecutePhase(ExecutionPhases executionPhases)
       at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.ExecuteEntryPoints()


    Fundacion del Camino

    Tuesday, January 30, 2018 11:41 AM

Answers

  • It is not possible to host Visio Control in an Excel Document level's task pane.

    Fundacion del Camino

    • Marked as answer by Eduardo7095 Friday, March 9, 2018 1:35 PM
    Friday, March 9, 2018 1:35 PM

All replies

  • Hi Eduardo,

    I notice your issue is related to Excel VSTO. This forum focuses on general discussion for Visio application which is a drawing app.

    To better fix the issue, I move the thread to VSTO forum for more suggestion. Thanks for your understanding.


    Best Regards,
    Winnie Liang


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Wednesday, January 31, 2018 7:08 AM
  • Thanks! I didn't realized that there is a VSTO forum

    Fundacion del Camino

    Wednesday, January 31, 2018 3:04 PM
  • Hi Eduardo7095,

    You had mentioned that,"While attempting to use the Visio Control in a Document Task Pane, I get several issues and the control does not work. The control works fine in a regular form and even a UserControl (which I tried to embed to later use from Excel VSTO."

    Based on Article below Task pane and User Control consider as a same control.

    How to: Add a Custom Task Pane to an Application

    You had mentioned that Your control is working fine in User Control and not working in Task pane.

    I want to confirm with you which exact control you are using for your task pane and which visio control you want to add in your task pane.

    We will try to make a test on our side and try to provide you further suggestions.

    If possible then you can also try to share sample project which can give us exact idea about the issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 2, 2018 7:09 AM
    Moderator
  • Thanks Deepak.

    When I said that the Visio control works fine in a "user control project" I meant a stand alone "Visual C# -> Windows Classic Desktop -> Windows Forms Control Library (.NET Framework)".

    The Visio Control also works in a regular "Visual C# -> Windows Classic Desktop -> Windows Forms App (.NET Framework)"

    The issue is when I try to use the Visio Control in a "Visual C# -> Office/Sharepoint -> Excel 2013 and 2016 VSTO Workbook". 

    In a brand new Excel 2013 and 2016 VSTO Workbook project, I add a 'Actions Pane Control'. I then drop the Visio Control on my Actions Pane Control.  

    I add a few lines to show the Task Pane as follows.

      Workflow WF = new Workflow(); //My Actions Pane Control is called 'Workflow
      this.ActionsPane.Controls.Add(WF);

    When I Debug/Run my project, I get the exception at this line that was automatically generated by the Designer.:

    ((System.ComponentModel.ISupportInitialize)(this.axDrawingControl2)).EndInit();

    We are currently considering Telerik Diagram tools, but would prefer to work with Visio.

    Thanks,

    Ramon Aldana


    Fundacion del Camino

    P.S. Do you still want me to share a project to replicate this? It is failing with those 3 simple steps.

    1. Create Excel Document VSTO

    2. Add task pane + visio control

    3. add code to show the taskpane and run the project.


    • Edited by Eduardo7095 Thursday, February 22, 2018 2:43 PM
    • Marked as answer by Eduardo7095 Friday, March 9, 2018 1:34 PM
    • Unmarked as answer by Eduardo7095 Friday, March 9, 2018 1:34 PM
    Thursday, February 15, 2018 8:43 PM
  • It is not possible to host Visio Control in an Excel Document level's task pane.

    Fundacion del Camino

    • Marked as answer by Eduardo7095 Friday, March 9, 2018 1:35 PM
    Friday, March 9, 2018 1:35 PM