'From https://www.cadlinecommunity.co.uk/hc/en-us/articles/203139401 ' reworked, KraBBy 2020-01-30 Const oHoldingPositionName As String = "Prt_No" 'KraBBy: Name of the Parameter 'Dim oValue As String = iProperties.Value("Project", "Part Number") 'Value: iProperty Dim oValue As String ' Dim oDoc as Object = ThisApplication.ActiveDocument 'Check to see if this is a part file If oDoc.DocumentType <> kPartDocumentObject Then ' MessageBox.Show("This rule can only be run in a " & DocType & " file - exiting rule...", "Cadline Community") ' KraBBy: i don't want a message Return End If '---- added to get the FileName 2020-01-31 oValue = oDoc.FullFileName 'with path and file extension oValue = Mid(oValue, InStrRev(oValue, "\")+1) 'without path; incl. file extension oValue = Left(oValue, Len(oValue)-4) 'without file ext. '--- Dim oPartCompDef As PartComponentDefinition = oDoc.ComponentDefinition Dim oNewParameter As Parameters = oPartCompDef.Parameters Dim oUParameter As UserParameters = oNewParameter.UserParameters Dim oParam As Parameter If ""=oValue Then MsgBox("iProperty 'part No.' is empty!") Try oParam = oUParameter.Item(oHoldingPositionName) 'get the existing Param. oParam.Value = oValue 'change/update its value 'MsgBox("Param. changed") 'for debugging Catch 'Parameter doesn't exist, create it! oParam = oUParameter.AddByValue(oHoldingPositionName, (oValue), "text") 'MsgBox("Param. created") 'for debugging End Try oDoc.Update() 'Updates the document