![]() |
|
#2
|
||||
|
||||
|
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 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Add custom doc properties in "Doc properties control" | eazysnatch | Word | 2 | 09-13-2017 08:08 PM |
Searching with Custom Properties
|
jpb103 | Word VBA | 6 | 05-30-2014 07:08 AM |
Changing Default Author on New Word 2013 Documents
|
chaplaindoug | Word | 1 | 01-09-2014 12:00 PM |
| Custom Properties | b-baker | Word | 1 | 03-01-2012 01:15 AM |
| Looping though Custom Properties in VBA | suekay | Misc | 0 | 05-19-2006 06:10 AM |