3 Replies Latest reply on Nov 7, 2013 5:53 PM by Artem Taturevych

    Example Add ActiveX Tabs to Model View (VBA) doesn't work

    Manfred Kern

      I want to create a tab in the model view with my own activeX control. First i tried the API example. This doesn't work! The function -addcontrol- returns nothing. I'm using SW2012.

      Any suggestions?

       

      Thx

       

      Manfred

        • Re: Example Add ActiveX Tabs to Model View (VBA) doesn't work
          Artem Taturevych

          What control are you adding? Please note that this control has to be registered as COM object.

            • Re: Example Add ActiveX Tabs to Model View (VBA) doesn't work
              Manfred Kern

              Hi Artem

               

              The MSACAL.OCX Object

              Here is the example from SW :

               

              Imports SolidWorks.Interop.sldworks

              Imports SolidWorks.Interop.swconst

              Imports System

              Imports MSACAL

               

              Sub Main()

                  Const calTabName1 As String = "Calendar 1"
                  Const calTabName2 As String = "Calendar 2"
                  Dim swApp As SldWorks.SldWorks
                  Dim swModel As SldWorks.ModelDoc2
                  Dim swModViewMgr As SldWorks.ModelViewManager
                  Dim calCtrl1 As MSACAL.Calendar
                  Dim calCtrl2 As MSACAL.Calendar
                  Dim fileName As String
                  Dim errors As Long
                  Dim warnings As Long
                  Dim status  As Boolean
                  Set swApp = CreateObject("SldWorks.Application")
                
                  Set swModel = swApp.ActiveDoc
                  Set swModViewMgr = swModel.ModelViewManager
                  ' Add the ActiveX control tabs
                  Set calCtrl1 = swModViewMgr.AddControl(calTabName1, "MSCAL.Calendar", "")
                  Set calCtrl2 = swModViewMgr.AddControl(calTabName2, "MSCAL.Calendar", "")
                  ' Set the background colors for the ActiveX controls
                  calCtrl1.BackColor = RGB(255, 0, 0) 'red
                  calCtrl2.BackColor = RGB(0, 0, 0) 'black
                  status = swModViewMgr.ActivateControlTab(calTabName1)
                  status = swModViewMgr.IsControlTabActive(calTabName1)
                  status = swModViewMgr.IsModelTabActive
                  ' Switch back to model view
                  status = swModViewMgr.ActivateModelTab
              End Sub

              Thx
              Manfred