hope this help
Private Sub UserForm_Activate()
' Get the active document.
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
' Get the PropertySets object.
Dim oPropSets As PropertySets
Set oPropSets = oDoc.PropertySets
' Get the design tracking property set.
Dim oPropSet As PropertySet
Set oPropSet = oPropSets.item("Design Tracking Properties")
' Get the part number iProperty.
Dim oPartNumiProp As Property
Set oPartNumiProp = oPropSet.item("Part Number")
' Get the Part Name iProperty.
Dim oStockNumiProp As Property
Set oStockNumiProp = oPropSet.item("Stock Number")
' Get the Surface Treatment iProperty.
Dim oDescriptioniProp As Property
Set oDescriptioniProp = oPropSet.item("Description")
'Get the material iProperty.
Dim oMaterialiProp As Property
Set oMaterialiProp = oPropSet.item("Material")
'Get the designer iProperty.
Dim oDesigneriProp As Property
Set oDesigneriProp = oPropSet.item("Designer")
'Get the Authority iProperty.
Dim oAuthorityiProp As Property
Set oAuthorityiProp = oPropSet.item("Authority")
' Get the PropertySets object.
Dim oPropSetsHeat As PropertySets
Set oPropSetsHeat = oDoc.PropertySets
' Get the design tracking property set.
Dim oPropSetHeat As PropertySet
Set oPropSetHeat = oPropSets.item("Inventor User Defined Properties")
Dim oHeatiProp As Property
Set oHeatiProp = oPropSetHeat.item("XXX")
'--------------------------------------------------
'Read Unit name
UnitNameCombo.Value = Left(oDoc.DisplayName, 2)
'Read Part name
PartNoTextBox.Text = oDoc.DisplayName
'BACK UP PART NAME
'Read Part no
PartNameTextBox.Text = oAuthorityiProp.Value
'Read material
MaterialCombo.Value = oMaterialiProp.Value
'Read surface treatment
SurfaceCombo.Value = oDescriptioniProp.Value
'Read designer
DesignCombo.Value = oDesigneriProp.Value
'Read heat
HeatCombo.Value = oHeatiProp.Value
'--------------------------------------------------
End Sub
Private Sub SaveButton_Click()
' Get the active document.
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
' Get the PropertySets object.
Dim oPropSets As PropertySets
Set oPropSets = oDoc.PropertySets
' Get the design tracking property set.
Dim oPropSet As PropertySet
Set oPropSet = oPropSets.item("Design Tracking Properties")
' Get the part number iProperty.
Dim oPartNumiProp As Property
Set oPartNumiProp = oPropSet.item("Part Number")
' Get the Part Name iProperty.
Dim oStockNumiProp As Property
Set oStockNumiProp = oPropSet.item("Stock Number")
' Get the Surface Treatment iProperty.
Dim oDescriptioniProp As Property
Set oDescriptioniProp = oPropSet.item("Description")
' Get the material iProperty.
Dim oMaterialiProp As Property
Set oMaterialiProp = oPropSet.item("Material")
'Get the designer iProperty.
Dim oDesigneriProp As Property
Set oDesigneriProp = oPropSet.item("Designer")
'' Get the Creation Time iProperty.
'Dim oCreationTimeiProp As Property
'Set oCreationTimeiProp = oPropSet.Item("Creation Time")
'' Uncheck the Creation Time iProperty.
'oCreationTimeiProp.Expression = "1601, 1, 1"
'Get the Authority iProperty.
Dim oAuthorityiProp As Property
Set oAuthorityiProp = oPropSet.item("Authority")
'Get the Costcenter iProperty.
Dim oCostCenteriProp As Property
Set oCostCenteriProp = oPropSet.item("Cost Center")
' Get the PropertySets object.
Dim oPropSetsHeat As PropertySets
Set oPropSetsHeat = oDoc.PropertySets
' Get the design tracking property set.
Dim oPropSetHeat As PropertySet
Set oPropSetHeat = oPropSets.item("Inventor User Defined Properties")
Dim oHeatiProp As Property
Set oHeatiProp = oPropSetHeat.item("XXX")
' -------------------------------------
If oDoc.DocumentType = kPartDocumentObject Then
'Assign Part No
oPartNumiProp.Value = UCase(PartNameTextBox.Text)
'Back up Part No
oAuthorityiProp.Value = UCase(PartNameTextBox.Text)
'Assign Part Name
oStockNumiProp.Value = UCase(PartNoTextBox.Text)
'Assign Material
Dim oMaterial As Material
Set oMaterial = oDoc.Materials.item(MaterialCombo.Value)
oDoc.ComponentDefinition.Material = oMaterial
'Assign Surface Treatment
oDescriptioniProp.Value = SurfaceCombo.Value
'Assign designer
oDesigneriProp.Value = UCase(DesignCombo.Value)
'Assign heat treatment
oHeatiProp.Value = UCase(HeatCombo.Value)
End If
'--------------------------------------
Unload Me
oDoc.Save2 (True)
End Sub