3 Replies Latest reply on Jul 7, 2016 2:19 AM by Jean-Baptiste Bouckaert

    From Textbox To configuration file

    Jean-Baptiste Bouckaert

      I have written a little macro where I can type the values wich I want to edit in my configuration file in a couple of textboxes. For some reason the program actually works but it gives me an "object variable not set" error at the line wich I have surrounded by the exclamation mark. Does anyone know why?

       

      The PropertyEdit function is triggered by pressing a commandbutton.

       

      Dim swApp As Object

      Dim swCustPropMgr As SldWorks.CustomPropertyManager

      Dim swModel As SldWorks.ModelDoc2

      Dim DwgNumber As String

      Dim Title As String

      Dim Customer As String

      Dim Designer As String

      Dim Revision As String

       

       

      Sub main()

       

      Set swApp = Application.SldWorks

      Set swModel = swApp.ActiveDoc

      Set swCustPropMgr = swModel.Extension.CustomPropertyManager(Empty)

       

       

      UserForm1.Show

       

       

      End Sub

       

      Function PropertyEdit()

       

      DwgNumber = UserForm1.txt_DwgNumber.Text

      Title = UserForm1.txt_Title.Text

      Customer = UserForm1.txt_Customer.Text

      Designer = UserForm1.txt_Designer.Text

      Revision = UserForm1.txt_Revision.Text

       

      !!!swCustPropMgr.Set "dwgnumber", DwgNumber!!!

      swCustPropMgr.Set "title", Title

      swCustPropMgr.Set "customer", Customer

      swCustPropMgr.Set "Drawnby", Designer

      swCustPropMgr.Set "revision", Revision

       

       

      End Function