4 Replies Latest reply on Mar 22, 2017 8:53 PM by Clint Clark

    Help with Compile error '=' expected

    Clint Clark

      I am new to Solidworks and I am trying to automate some drawing tasks.

      Can someone please tell me why the following code won't compile? The error is Expected '=' at the bold line.

       

      ' *****************************************************************************

      Dim swApp As Object

       

       

      Dim Part As Object

      Dim boolstatus As Boolean

      Dim longstatus As Long, longwarnings As Long

       

       

      Sub main()

       

       

      Dim swDraw As SldWorks.DrawingDoc

      Dim myModelView As Object

      Dim vwView As SldWorks.View

      Dim swDispDim                   As SldWorks.DisplayDimension

      Dim swDim                       As SldWorks.Dimension

      Dim swAnn                       As SldWorks.Annotation

      Dim iDimsCount                  As Integer

       

      Set swApp = Application.SldWorks

      Set Part = swApp.ActiveDoc

      Set swDraw = Part

      Set swView = Part.GetFirstView

       

      iDimsCount = 1

       

      Do While Not swView Is Nothing

          Set swDispDim = swView.GetFirstDisplayDimension5

         

          Dim sViewName As String

         

          'sViewName = swView.GetName()

         

          Do While Not swDispDim Is Nothing

              Dim sDim As String

             

              sDim = swDispDim.GetText(swDimensionTextAll)

              sDim = swDispDim.GetText(swDimensionTextPrefix)

              sDim = "<C#-" & iDimsCount & ">" & sDim

              swDispDim.SetText(swDimensionsPrefix, sDim)

                 

              'Set swAnn = swDispDim.GetAnnotation

              'Set swDim = swDispDim.GetDimension

             

              'iResult = MsgBox(swDim.Value & ":" & swAnn.GetStyleName, vbOKOnly, "Dim box")

             

              iDimsCount = iDimsCount + 1

              Set swDispDim = swDispDim.GetNext3   

          Loop

         

           Set swView = swView.GetNextView

      Loop

       

      iResult = MsgBox(iDimsCount - 1, vbOKOnly, "Total Dims Found")

      'Set myModelView = Part.ActiveView

      'myModelView.FrameState = swWindowState_e.swWindowMaximized

       

      End Sub