#1
|
|||
|
|||
CustomDocumentProperties not shown in header / footer / textfield
Hello,
I added some CustomDocumentProperties to my document which should be filled with a VBA form When I open the form, fill out the fields and want to populate the entries to the custom fields in my document, only the ones which are in the text itself are added. The fields which I added in header/footer or in textfields in the document are not filled. This ist the code of the button click in the VBA Form: Code:
Private Sub inpDocGenerate_Click() ' Update the properties values ActiveDocument.CustomDocumentProperties("customDocType").Value = Me.inpDocType.Value ActiveDocument.CustomDocumentProperties("customClientName").Value = Me.inpClientName.Value ActiveDocument.CustomDocumentProperties("customDocTitle").Value = Me.inpDocTitle.Value ActiveDocument.CustomDocumentProperties("customOfferNum").Value = Me.inpOfferNum.Value ActiveDocument.CustomDocumentProperties("customDate").Value = Me.inpDate.Value ActiveDocument.CustomDocumentProperties("customCity").Value = Me.inpCity.Value ActiveDocument.CustomDocumentProperties("customAspName").Value = Me.inpAspName.Value ' Show changes of document properties in document ActiveDocument.Fields.Update ' Hide the userform UserForm1.Hide End Sub |
#2
|
||||
|
||||
Only the fields in the main story range are updated using your code. Instead of using
Code:
ActiveDocument.Fields.Update Code:
Sub UpdateAllFields() Dim oStory As Range For Each oStory In ActiveDocument.StoryRanges oStory.Fields.Update If oStory.StoryType <> wdMainTextStory Then While Not (oStory.NextStoryRange Is Nothing) Set oStory = oStory.NextStoryRange oStory.Fields.Update Wend End If Next oStory lbl_Exit: Set oStory = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Nice! This did the trick.
Thank you! |
#4
|
|||
|
|||
Quote:
He also has at least three pages of example macros. One of them is: VBA Code Examples (3) by Graham Mayor, MVP. His main page is: Microsoft Word Tips by Graham Mayor, MVP If you are going to be using vba, I recommend strongly that you become familiar with his site as well as the MVP page: Word Macros and Visual Basic for Applications (VBA) FAQ and Greg Maxey's site: Microsoft Word Help, Tips and Tutorials @ The Anchorage |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adding text to the header and footer without removing all other content in the header and footer | digitalelise | Word VBA | 2 | 10-23-2019 02:58 AM |
Get CustomDocumentProperties | vince692 | Word VBA | 8 | 05-13-2016 12:34 AM |
Header and footer aligned in the footer area | ashiqghfr | Word | 2 | 07-23-2015 01:14 AM |
Document Variables vs CustomDocumentProperties | Cosmo | Word VBA | 2 | 08-11-2014 01:35 PM |
Set focus on a textfield on a repeating table | happydigit | Misc | 0 | 11-24-2005 04:12 AM |