Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-03-2016, 06:58 AM
JonFleming JonFleming is offline Updating a custom property in the header Windows 10 Updating a custom property in the header Office 2016
Novice
Updating a custom property in the header
 
Join Date: Feb 2016
Posts: 15
JonFleming is on a distinguished road
Default Updating a custom property in the header

I'm working on a macro for a document to submit to the FDA. There's a bunch of items that appear many many times in the document and change when you start a new document. There's also a bunch of technical reasons why plain search and replace doesn't work and takes along time to fail.

So I've defined a custom property for each of these items. There's a table at the beginning of the document with the property names in the first column. The user fills in the second column with the desired value. My macro extracts the information from the table and changes the property value, turns off screen updating, then updates all instances of the property:



Code:
Sub UpdateSpecificPropertyFields(FieldName As String)
    Dim pRange As Word.Range
    Dim oFld As Word.Field
    For Each pRange In ActiveDocument.StoryRanges
        Do
            For Each oFld In pRange.Fields
                Select Case oFld.Type
                    Case wdFieldDocProperty
                        If InStr(oFld.Code.Text, FieldName) Then
                            oFld.Update
                        End If
                    Case Else
                       'Do nothing
                End Select
            Next
            Set pRange = pRange.NextStoryRange
        Loop Until pRange Is Nothing
    Next
End Sub
But the instances of the property in the header do not get updated. Help?
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating a custom property in the header Update Custom Document Property in Template Byron Polk Word VBA 10 08-19-2014 07:19 AM
Updating a custom property in the header Insert image based on document custom property anandyrh Word 1 08-14-2013 12:08 AM
Custom Document Property Lost From Template bhaughey Word 8 03-05-2013 02:11 PM
Link Watermark to custom property kerend Word 0 04-08-2012 05:03 AM
Updating a custom property in the header QuickParts - custom document property untttt Word 2 06-09-2011 05:24 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:18 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