View Single Post
 
Old 09-24-2015, 12:22 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following macro function when used in conjunction with http://www.gmayor.com/document_batch_processes.htm as a custom process will add the custom docproperty 'Department' to either the current document or a folder full of documents (including sub folders if you wish). If the property is already present it will be updated with the value entered, which from your illustrations appears to be 'Money'

You can change the Constants to reflect any custom property name, value or type


Code:
Option Explicit

Function DocProp(oDoc As Document) As Boolean
Dim oProp As DocumentProperty
Dim bProp As Boolean

Const strName As String = "Department"
Const strValue As String = "Money"
Const lngType As Long = 4        'Text

    On Error GoTo err_Handler

    bProp = False
    For Each oProp In oDoc.CustomDocumentProperties
        If oProp.name = strName Then
            oProp.Value = strValue
            bProp = True
            Exit For
        End If
    Next oProp
    If Not bProp Then
        oDoc.CustomDocumentProperties.Add _
                name:=strName, _
                LinkToContent:=False, _
                Value:=strValue, _
                Type:=lngType
    End If
    DocProp = True
lbl_Exit:
    Exit Function
err_Handler:
    DocProp = False
    Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote