Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 09-24-2015, 12:22 AM
gmayor's Avatar
gmayor gmayor is offline Changing custom properties in multiple word documents Windows 7 64bit Changing custom properties in multiple word documents Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 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
 



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
Changing custom properties in multiple word documents Searching with Custom Properties jpb103 Word VBA 6 05-30-2014 07:08 AM
Changing custom properties in multiple word documents 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

Other Forums: Access Forums

All times are GMT -7. The time now is 09:11 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft