cannot update footer docvariable

B

btmcfadden

I am trying to update docvariables in a word document from Access. This code
will update the variables on the second page but does not update the variable
on the first page - when I am in the footer it is labeled "section1"... Why
is this not working??

If (strApproval) = "Yes" Then
'edits and updates footer field for docname
oDoc.Variables("TCSName").Value = strName
oDoc.Variables("FirstVersion").Value = strVersion
oDoc.Variables("FVersion").Value = strVersion
oDoc.Sections(1).Footers(wdHeaderFooterPrimary).Range.Fields.Update
'sets default path
oApp.Options.DefaultFilePath(wdDocumentsPath) = "C:\"
oApp.ActiveDocument.Save
oApp.Quit
Set oDoc = Nothing
Set oApp = Nothing
GoTo Exit1:
End If
 
C

Charles Kenyon

Chances are your document section is set for a different first page
header/footer. If so, you are only changing the continuation footer. Try
something like:

oDoc.StoryRanges(wdFirstPageFooterStory).Fields.Update

WARNING: docvariable fields in Word 97 in the header or footer cause the
program to crash.

See the Fields links at http://addbalance.com/word/wordwebreferences.htm for
a link to a macro that updates all fields in a document, regardless of which
storyrange the field may be found in.
 
B

btmcfadden

Thank you, I'll try that! Now, forgive my ignorance please! But, when you
say my document section is set for a different first page, how would that
have been done? I have a different footer on the first page vs. the
continuing - is that what you mean?! Sorry, obviously, I'm learning
(always!)!!!

THANKS!!!!!
 
T

TRM

Thanks, I'll try that! However, for future reference... when you say the
document section is set for a different first page, would that be because I
have set the first page footer one way and then a different footer for
following pages?? Is that what you are referring to? If it's not, I don't
know why it would be set differently and would love to have more information
on that! Actually, even if that is it, I guess I'm not sure why the first
page wouldn't still be considered the section 1 or the primary page... as
code would imply!? Sorry - forgive my ignorance please! Obviously I'm
learning (all the time!).

Thanks so much for your time and help!
 
T

TRM

Thanks, this worked! Still don't quite understand why... if you have
reference materials/articles, one this particular thing, please note them!
THANKS again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top