Update Doc Property field in text box using automation

I have a word template that is used to create a new document from within an Access database. When the Access VBA routine is run, data from Database is used to update the document properties of a new word document based on my template. This works fine and the document is created correctly, properties are filled with daa and bookmarks are filled with text as appropriate.

The document template has a number of fields in the header including three text boxes. These update fine and display the correct information.

The main body of the document has two text boxes with fields in them but these do not get updated along with everything else. The information is in the custom document property but currently these fields have to be updated manually.

The code usedto update the fields within the document is as follows... (appword is my word document object)

With appword
.Visible = True
.Activate
.Selection.WholeStory
.Selection.Fields.Update
End With

The file needs to be saved before the field will display the file name and path. It will show up in a header because by the time you see it, the header will have been refreshed automatically during Word's pagination. Try saving it first, then update the fields and save it a second time.

Version: Word 2003
Fields types. They are custom docvument properties. All strings (i dont think there any other types)

I am using text boxes to get two distinct pieces of information in two columns. I do not want the infomration form the first column spilling into the second column and I the length of the text could vary considerably so I put the field codes in text boxes and positioned them next to each other. I have done exaclty the same in the header and it seems to work perfectly !!

If there is a better way to acieve the same layout I would glady implement it.

EricFletcher

The filename and path are showing up in the footer just fine. There is another save which I did not include in my source which does exactly what you have described. The fields which do not getupdated are Custom document properties.

Oh my goodness snave - not to worry. We all have those "moments" - although mine now fall in the category of "senior moments" *sobbing and laughing at the same time*

I would just select the text you have in one text box, press Control C to copy it (assuming it's more than a couple lines), then delete the text box and paste it where you want it to appear. If its a lot of text, you could select the text, go to Table, Convert Text to Table, and then create a one column table. Then select the table, and split the columns into two. In the checkbox where it says to merge cells (or something like that) before splitting, uncheck it.

Do the same with the second text box and format as desired. Past that into the second column of the table you created above. If you need more help, please let me know. I had some medical tests done this morning and am feeling REALLY GOOD due to the anesthetic - so catch me while I'm up. I'll probably be crashing within a few hours!

So far, I've only been addressing the issue of the text boxes but if you need help with filename/path info - I've got a lot of experience with that as well - as I know Eric does from the wonderful information he posts.

When this section executes the word document view changes to Normal view with the footer expanded in a separate window/section at the bottom of the page. Is there any way to either prevent this from happening or change the view back to print layout view via code.

Preface:
When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…

This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …