18 Replies Latest reply on Jan 5, 2018 3:20 AM by Ivana Kolin

    Update to Office 2013 has VBA code not working

    Will Speaker

      I'm using VBA to change property fields in a drawing.  I just upgraded my computer which is now running Office 2013 and my code doesn't work anymore.  I get an error message of "Compile error: Can't find project or library" when I try to execute the following code.  Additionally, the text "swCustomInfoText" is highlighted by the debugging program.

       

      Sub ChangeProperties()

      Dim swApp, Part As Object

      Dim boolstatus, retval As Boolean

      Dim swModel As SldWorks.ModelDoc2

      Set swApp = CreateObject("sldworks.application")

      swApp.Visible = True

       

      FilePath = DirectoryPath & "\" & DrawingFileName

      swApp.OpenDoc FilePath, 3

      Set Part = swApp.ActiveDoc

       

      retval = Part.DeleteCustomInfo2("", "DrawnDate")

      retval = Part.AddCustomInfo3("Default", "DrawnDate", swCustomInfoText, VBA.Format(VBA.Date, "m/d/yy"))

       

      boolstatus = Part.EditRebuild3()

       

      End Sub