1 Reply Latest reply on May 12, 2016 5:55 PM by Nic Brunsting

    Write to Property Tab Builder's Date field with Date format through VBA

    Nic Brunsting

      Hi All,

       

      I have a macro written that populates custom properties with values.  One is initials of the current user, the other is the current date.  The desired effect is to populate a "Created By" and "Created Date" when the user first saves the file.  We use the Property Tab Builder with a date format so while in the part, you can select the current date from the calendar drop down.

       

      My macro populates the two fields using this code: [swCustPropMgr.Set "DESIGNED DATE", Date] and it seems to work fine in the actual properties tab (Summary Information > Custom).  However, because of the date formatting in the property tab builder, it does not put any data into the property tab builder field.  When the part is saved, the blank data in the PTB overwrites the correct data in the properties (Summary Information > Custom).

       

      I've tried changing changing the formatting in the PTB from Date to Text, which doesn't help either.  I put a property underneath [SW-Short Date" and called it "Date Format" to encourage proper date formatting.

       

      Is it a problem with writing a date to the PTB?  Any help in writing to the date field with a date or text format?

       

      Thanks,

      Nic

        • Re: Write to Property Tab Builder's Date field with Date format through VBA
          Nic Brunsting

          I discovered that there was a problem writing to the property tab builder while it was active.  By changing to another tab, populating the information, then switching back, I was able to get it working.  Here is the code I used:

           

          'switches to Design library tab so properties can update

              swApp.ActivateTaskPane swDesignLibrary

             

          'Populates Designed By custom property with user's initials

              swCustPropMgr.Set "DESIGNED BY", userinitials

          'Populates Designed Date custom property with current date

              swCustPropMgr.Set "DESIGNED DATE", Date

             

          'switches back to custom props tab

              swApp.ActivateTaskPane swCustomProps