Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
deb deb is offline
external usenet poster
 
Posts: 111
Default Automatic Filename Update

A few years ago, I created a protected form which has a footer containing a
filename field that would update as a user copied and renamed the file.
Recently, the filename has not been updating. F9 works, but you have to
unprotect and resave the document, and when tested, also does not change the
filename when renamed to a new file. Also found a macro which works as F9
does. To do these steps would be like re-inventing the wheel. The purpose
of this form was to make it user-proof and setup up general forms for each
client we have - all a user needed to do was fill in specific info, such as
account amounts, and the form would update the filename and retain the basic
client info. Did Microsoft change something? And how can I get my nice
little feature back? Any help will be greatly appreciated. Thanks!
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Automatic Filename Update

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is unbelievably
bogus -- but using a series of macros is the only way to avoid needing manual
updating. Besides the AutoOpen macro shown in the KB article, you would also
need one that intercepts the Save As command and saves, updates the field, and
saves again (the first save changes the name of the file, but updating the field
"dirties" the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb wrote:

A few years ago, I created a protected form which has a footer containing a
filename field that would update as a user copied and renamed the file.
Recently, the filename has not been updating. F9 works, but you have to
unprotect and resave the document, and when tested, also does not change the
filename when renamed to a new file. Also found a macro which works as F9
does. To do these steps would be like re-inventing the wheel. The purpose
of this form was to make it user-proof and setup up general forms for each
client we have - all a user needed to do was fill in specific info, such as
account amounts, and the form would update the filename and retain the basic
client info. Did Microsoft change something? And how can I get my nice
little feature back? Any help will be greatly appreciated. Thanks!

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
deb deb is offline
external usenet poster
 
Posts: 111
Default Automatic Filename Update

Well....grrrrrrrr.... Thank you for responding so quickly. Macros are not
working within the documents - the option is greyed out due I suppose to the
forms being protected. I found another macro that will change text in
batches, and since the filename changes would for the most part be the fiscal
year, do you think that would work? Would a macro for changing text in
batches of files work if the files are protected forms? I really, truly,
absolutely, do not want to have to update each and every file individually.
And whatever happened to the adage, 'if it ain't broke, don't fix it'???
Hope you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is unbelievably
bogus -- but using a series of macros is the only way to avoid needing manual
updating. Besides the AutoOpen macro shown in the KB article, you would also
need one that intercepts the Save As command and saves, updates the field, and
saves again (the first save changes the name of the file, but updating the field
"dirties" the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb wrote:

A few years ago, I created a protected form which has a footer containing a
filename field that would update as a user copied and renamed the file.
Recently, the filename has not been updating. F9 works, but you have to
unprotect and resave the document, and when tested, also does not change the
filename when renamed to a new file. Also found a macro which works as F9
does. To do these steps would be like re-inventing the wheel. The purpose
of this form was to make it user-proof and setup up general forms for each
client we have - all a user needed to do was fill in specific info, such as
account amounts, and the form would update the filename and retain the basic
client info. Did Microsoft change something? And how can I get my nice
little feature back? Any help will be greatly appreciated. Thanks!


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Automatic Filename Update

If you put the filename field in the body of the document rather than the
footer and check the calculate on exit check box of one of the fields that
you will tab out of, the field will be updated.
or
You could add an update macro to the toolbar

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub

Batch macros will work on protected forms -
http://www.gmayor.com/batch_replace.htm provided the extra code to unlock
the forms where required is included. eg

Dim bProtected As Boolean
Dim sPassword As String
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Well....grrrrrrrr.... Thank you for responding so quickly. Macros
are not working within the documents - the option is greyed out due I
suppose to the forms being protected. I found another macro that
will change text in batches, and since the filename changes would for
the most part be the fiscal year, do you think that would work?
Would a macro for changing text in batches of files work if the files
are protected forms? I really, truly, absolutely, do not want to
have to update each and every file individually. And whatever
happened to the adage, 'if it ain't broke, don't fix it'??? Hope
you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is
unbelievably bogus -- but using a series of macros is the only way
to avoid needing manual updating. Besides the AutoOpen macro shown
in the KB article, you would also need one that intercepts the Save
As command and saves, updates the field, and saves again (the first
save changes the name of the file, but updating the field "dirties"
the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb
wrote:

A few years ago, I created a protected form which has a footer
containing a filename field that would update as a user copied and
renamed the file. Recently, the filename has not been updating. F9
works, but you have to unprotect and resave the document, and when
tested, also does not change the filename when renamed to a new
file. Also found a macro which works as F9 does. To do these
steps would be like re-inventing the wheel. The purpose of this
form was to make it user-proof and setup up general forms for each
client we have - all a user needed to do was fill in specific info,
such as account amounts, and the form would update the filename and
retain the basic client info. Did Microsoft change something? And
how can I get my nice little feature back? Any help will be
greatly appreciated. Thanks!



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
deb deb is offline
external usenet poster
 
Posts: 111
Default Automatic Filename Update

Thanks, Graham. It's funny - got the batch code from your site yesterday,
but not the additional protect/unprotect code. Cute kitties you have on
there. I will try each of the things offered in the posts from you and Jay.
Will add to this post with what actually worked best. Thanks again!

"Graham Mayor" wrote:

If you put the filename field in the body of the document rather than the
footer and check the calculate on exit check box of one of the fields that
you will tab out of, the field will be updated.
or
You could add an update macro to the toolbar

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub

Batch macros will work on protected forms -
http://www.gmayor.com/batch_replace.htm provided the extra code to unlock
the forms where required is included. eg

Dim bProtected As Boolean
Dim sPassword As String
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Well....grrrrrrrr.... Thank you for responding so quickly. Macros
are not working within the documents - the option is greyed out due I
suppose to the forms being protected. I found another macro that
will change text in batches, and since the filename changes would for
the most part be the fiscal year, do you think that would work?
Would a macro for changing text in batches of files work if the files
are protected forms? I really, truly, absolutely, do not want to
have to update each and every file individually. And whatever
happened to the adage, 'if it ain't broke, don't fix it'??? Hope
you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is
unbelievably bogus -- but using a series of macros is the only way
to avoid needing manual updating. Besides the AutoOpen macro shown
in the KB article, you would also need one that intercepts the Save
As command and saves, updates the field, and saves again (the first
save changes the name of the file, but updating the field "dirties"
the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb
wrote:

A few years ago, I created a protected form which has a footer
containing a filename field that would update as a user copied and
renamed the file. Recently, the filename has not been updating. F9
works, but you have to unprotect and resave the document, and when
tested, also does not change the filename when renamed to a new
file. Also found a macro which works as F9 does. To do these
steps would be like re-inventing the wheel. The purpose of this
form was to make it user-proof and setup up general forms for each
client we have - all a user needed to do was fill in specific info,
such as account amounts, and the form would update the filename and
retain the basic client info. Did Microsoft change something? And
how can I get my nice little feature back? Any help will be
greatly appreciated. Thanks!






  #6   Report Post  
Posted to microsoft.public.word.docmanagement
deb deb is offline
external usenet poster
 
Posts: 111
Default Automatic Filename Update

Putting the filename in the body of the document would have required each
file to be edited, or recreated, individually. BUT THE SECOND OPTION, adding
the macro to the toolbar - WORKS PERFECTLY EVEN IN PROTECTED DOCUMENTS!
Created the macro, added it to the toolbar, and tested it. Opened different
protected files which had filename fieldcodes in footers, changed the other
data that I wanted to change, hit the macro button on the toolbar, instant
filename change in the protected documents' footers. Beautiful! Thank you
ever so much!

"Deb" wrote:

Thanks, Graham. It's funny - got the batch code from your site yesterday,
but not the additional protect/unprotect code. Cute kitties you have on
there. I will try each of the things offered in the posts from you and Jay.
Will add to this post with what actually worked best. Thanks again!

"Graham Mayor" wrote:

If you put the filename field in the body of the document rather than the
footer and check the calculate on exit check box of one of the fields that
you will tab out of, the field will be updated.
or
You could add an update macro to the toolbar

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub

Batch macros will work on protected forms -
http://www.gmayor.com/batch_replace.htm provided the extra code to unlock
the forms where required is included. eg

Dim bProtected As Boolean
Dim sPassword As String
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Well....grrrrrrrr.... Thank you for responding so quickly. Macros
are not working within the documents - the option is greyed out due I
suppose to the forms being protected. I found another macro that
will change text in batches, and since the filename changes would for
the most part be the fiscal year, do you think that would work?
Would a macro for changing text in batches of files work if the files
are protected forms? I really, truly, absolutely, do not want to
have to update each and every file individually. And whatever
happened to the adage, 'if it ain't broke, don't fix it'??? Hope
you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is
unbelievably bogus -- but using a series of macros is the only way
to avoid needing manual updating. Besides the AutoOpen macro shown
in the KB article, you would also need one that intercepts the Save
As command and saves, updates the field, and saves again (the first
save changes the name of the file, but updating the field "dirties"
the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb
wrote:

A few years ago, I created a protected form which has a footer
containing a filename field that would update as a user copied and
renamed the file. Recently, the filename has not been updating. F9
works, but you have to unprotect and resave the document, and when
tested, also does not change the filename when renamed to a new
file. Also found a macro which works as F9 does. To do these
steps would be like re-inventing the wheel. The purpose of this
form was to make it user-proof and setup up general forms for each
client we have - all a user needed to do was fill in specific info,
such as account amounts, and the form would update the filename and
retain the basic client info. Did Microsoft change something? And
how can I get my nice little feature back? Any help will be
greatly appreciated. Thanks!




  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Automatic Filename Update

A minor addition to the macro will ensure that it always shows the correct
filename

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
'****************
ActiveDocument.Save
'****************
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Putting the filename in the body of the document would have required
each file to be edited, or recreated, individually. BUT THE SECOND
OPTION, adding the macro to the toolbar - WORKS PERFECTLY EVEN IN
PROTECTED DOCUMENTS! Created the macro, added it to the toolbar, and
tested it. Opened different protected files which had filename
fieldcodes in footers, changed the other data that I wanted to
change, hit the macro button on the toolbar, instant filename change
in the protected documents' footers. Beautiful! Thank you ever so
much!

"Deb" wrote:

Thanks, Graham. It's funny - got the batch code from your site
yesterday, but not the additional protect/unprotect code. Cute
kitties you have on there. I will try each of the things offered in
the posts from you and Jay. Will add to this post with what actually
worked best. Thanks again!

"Graham Mayor" wrote:

If you put the filename field in the body of the document rather
than the footer and check the calculate on exit check box of one of
the fields that you will tab out of, the field will be updated.
or
You could add an update macro to the toolbar

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub

Batch macros will work on protected forms -
http://www.gmayor.com/batch_replace.htm provided the extra code to
unlock the forms where required is included. eg

Dim bProtected As Boolean
Dim sPassword As String
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Well....grrrrrrrr.... Thank you for responding so quickly. Macros
are not working within the documents - the option is greyed out
due I suppose to the forms being protected. I found another macro
that will change text in batches, and since the filename changes
would for the most part be the fiscal year, do you think that
would work? Would a macro for changing text in batches of files
work if the files are protected forms? I really, truly,
absolutely, do not want to have to update each and every file
individually. And whatever happened to the adage, 'if it ain't
broke, don't fix it'??? Hope you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is
unbelievably bogus -- but using a series of macros is the only way
to avoid needing manual updating. Besides the AutoOpen macro shown
in the KB article, you would also need one that intercepts the
Save As command and saves, updates the field, and saves again
(the first save changes the name of the file, but updating the
field "dirties" the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb
wrote:

A few years ago, I created a protected form which has a footer
containing a filename field that would update as a user copied
and renamed the file. Recently, the filename has not been
updating. F9 works, but you have to unprotect and resave the
document, and when tested, also does not change the filename
when renamed to a new file. Also found a macro which works as
F9 does. To do these steps would be like re-inventing the
wheel. The purpose of this form was to make it user-proof and
setup up general forms for each client we have - all a user
needed to do was fill in specific info, such as account amounts,
and the form would update the filename and retain the basic
client info. Did Microsoft change something? And how can I get
my nice little feature back? Any help will be greatly
appreciated. Thanks!



  #8   Report Post  
Posted to microsoft.public.word.docmanagement
deb deb is offline
external usenet poster
 
Posts: 111
Default Automatic Filename Update

Thanks, Graham! Will add the additional code to the macro today. Happy
Thursday!

"Graham Mayor" wrote:

A minor addition to the macro will ensure that it always shows the correct
filename

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
'****************
ActiveDocument.Save
'****************
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Putting the filename in the body of the document would have required
each file to be edited, or recreated, individually. BUT THE SECOND
OPTION, adding the macro to the toolbar - WORKS PERFECTLY EVEN IN
PROTECTED DOCUMENTS! Created the macro, added it to the toolbar, and
tested it. Opened different protected files which had filename
fieldcodes in footers, changed the other data that I wanted to
change, hit the macro button on the toolbar, instant filename change
in the protected documents' footers. Beautiful! Thank you ever so
much!

"Deb" wrote:

Thanks, Graham. It's funny - got the batch code from your site
yesterday, but not the additional protect/unprotect code. Cute
kitties you have on there. I will try each of the things offered in
the posts from you and Jay. Will add to this post with what actually
worked best. Thanks again!

"Graham Mayor" wrote:

If you put the filename field in the body of the document rather
than the footer and check the calculate on exit check box of one of
the fields that you will tab out of, the field will be updated.
or
You could add an update macro to the toolbar

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub

Batch macros will work on protected forms -
http://www.gmayor.com/batch_replace.htm provided the extra code to
unlock the forms where required is included. eg

Dim bProtected As Boolean
Dim sPassword As String
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Well....grrrrrrrr.... Thank you for responding so quickly. Macros
are not working within the documents - the option is greyed out
due I suppose to the forms being protected. I found another macro
that will change text in batches, and since the filename changes
would for the most part be the fiscal year, do you think that
would work? Would a macro for changing text in batches of files
work if the files are protected forms? I really, truly,
absolutely, do not want to have to update each and every file
individually. And whatever happened to the adage, 'if it ain't
broke, don't fix it'??? Hope you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is
unbelievably bogus -- but using a series of macros is the only way
to avoid needing manual updating. Besides the AutoOpen macro shown
in the KB article, you would also need one that intercepts the
Save As command and saves, updates the field, and saves again
(the first save changes the name of the file, but updating the
field "dirties" the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb
wrote:

A few years ago, I created a protected form which has a footer
containing a filename field that would update as a user copied
and renamed the file. Recently, the filename has not been
updating. F9 works, but you have to unprotect and resave the
document, and when tested, also does not change the filename
when renamed to a new file. Also found a macro which works as
F9 does. To do these steps would be like re-inventing the
wheel. The purpose of this form was to make it user-proof and
setup up general forms for each client we have - all a user
needed to do was fill in specific info, such as account amounts,
and the form would update the filename and retain the basic
client info. Did Microsoft change something? And how can I get
my nice little feature back? Any help will be greatly
appreciated. Thanks!




  #9   Report Post  
Posted to microsoft.public.word.docmanagement
DP DP is offline
external usenet poster
 
Posts: 162
Default Automatic Filename Update

Using Word 2007, windows XP. I copied this macro and started to install. I
copied it fine but got mixed up with the Modules and projects described in
your "Installing Macros From Listings" so closed the window. Tested anyway
and it seems to work - what problems am I causing by not getting it in the
right project / module. Beginning to think I'\'m better off manually
updating the field.


"Graham Mayor" wrote:

A minor addition to the macro will ensure that it always shows the correct
filename

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
'****************
ActiveDocument.Save
'****************
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Putting the filename in the body of the document would have required
each file to be edited, or recreated, individually. BUT THE SECOND
OPTION, adding the macro to the toolbar - WORKS PERFECTLY EVEN IN
PROTECTED DOCUMENTS! Created the macro, added it to the toolbar, and
tested it. Opened different protected files which had filename
fieldcodes in footers, changed the other data that I wanted to
change, hit the macro button on the toolbar, instant filename change
in the protected documents' footers. Beautiful! Thank you ever so
much!

"Deb" wrote:

Thanks, Graham. It's funny - got the batch code from your site
yesterday, but not the additional protect/unprotect code. Cute
kitties you have on there. I will try each of the things offered in
the posts from you and Jay. Will add to this post with what actually
worked best. Thanks again!

"Graham Mayor" wrote:

If you put the filename field in the body of the document rather
than the footer and check the calculate on exit check box of one of
the fields that you will tab out of, the field will be updated.
or
You could add an update macro to the toolbar

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub

Batch macros will work on protected forms -
http://www.gmayor.com/batch_replace.htm provided the extra code to
unlock the forms where required is included. eg

Dim bProtected As Boolean
Dim sPassword As String
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Well....grrrrrrrr.... Thank you for responding so quickly. Macros
are not working within the documents - the option is greyed out
due I suppose to the forms being protected. I found another macro
that will change text in batches, and since the filename changes
would for the most part be the fiscal year, do you think that
would work? Would a macro for changing text in batches of files
work if the files are protected forms? I really, truly,
absolutely, do not want to have to update each and every file
individually. And whatever happened to the adage, 'if it ain't
broke, don't fix it'??? Hope you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is
unbelievably bogus -- but using a series of macros is the only way
to avoid needing manual updating. Besides the AutoOpen macro shown
in the KB article, you would also need one that intercepts the
Save As command and saves, updates the field, and saves again
(the first save changes the name of the file, but updating the
field "dirties" the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb
wrote:

A few years ago, I created a protected form which has a footer
containing a filename field that would update as a user copied
and renamed the file. Recently, the filename has not been
updating. F9 works, but you have to unprotect and resave the
document, and when tested, also does not change the filename
when renamed to a new file. Also found a macro which works as
F9 does. To do these steps would be like re-inventing the
wheel. The purpose of this form was to make it user-proof and
setup up general forms for each client we have - all a user
needed to do was fill in specific info, such as account amounts,
and the form would update the filename and retain the basic
client info. Did Microsoft change something? And how can I get
my nice little feature back? Any help will be greatly
appreciated. Thanks!




  #10   Report Post  
Posted to microsoft.public.word.docmanagement
DP DP is offline
external usenet poster
 
Posts: 162
Default Automatic Filename Update

Using Word 2007, windows XP. I copied this macro and started to install. I
copied it fine but got mixed up with the Modules and projects described in
your "Installing Macros From Listings" so closed the window. Tested anyway
and it seems to work - what problems am I causing by not getting it in the
right project / module. Beginning to think I'\'m better off manually
updating the field.


"Graham Mayor" wrote:

A minor addition to the macro will ensure that it always shows the correct
filename

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
'****************
ActiveDocument.Save
'****************
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Putting the filename in the body of the document would have required
each file to be edited, or recreated, individually. BUT THE SECOND
OPTION, adding the macro to the toolbar - WORKS PERFECTLY EVEN IN
PROTECTED DOCUMENTS! Created the macro, added it to the toolbar, and
tested it. Opened different protected files which had filename
fieldcodes in footers, changed the other data that I wanted to
change, hit the macro button on the toolbar, instant filename change
in the protected documents' footers. Beautiful! Thank you ever so
much!

"Deb" wrote:

Thanks, Graham. It's funny - got the batch code from your site
yesterday, but not the additional protect/unprotect code. Cute
kitties you have on there. I will try each of the things offered in
the posts from you and Jay. Will add to this post with what actually
worked best. Thanks again!

"Graham Mayor" wrote:

If you put the filename field in the body of the document rather
than the footer and check the calculate on exit check box of one of
the fields that you will tab out of, the field will be updated.
or
You could add an update macro to the toolbar

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub

Batch macros will work on protected forms -
http://www.gmayor.com/batch_replace.htm provided the extra code to
unlock the forms where required is included. eg

Dim bProtected As Boolean
Dim sPassword As String
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Well....grrrrrrrr.... Thank you for responding so quickly. Macros
are not working within the documents - the option is greyed out
due I suppose to the forms being protected. I found another macro
that will change text in batches, and since the filename changes
would for the most part be the fiscal year, do you think that
would work? Would a macro for changing text in batches of files
work if the files are protected forms? I really, truly,
absolutely, do not want to have to update each and every file
individually. And whatever happened to the adage, 'if it ain't
broke, don't fix it'??? Hope you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is
unbelievably bogus -- but using a series of macros is the only way
to avoid needing manual updating. Besides the AutoOpen macro shown
in the KB article, you would also need one that intercepts the
Save As command and saves, updates the field, and saves again
(the first save changes the name of the file, but updating the
field "dirties" the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb
wrote:

A few years ago, I created a protected form which has a footer
containing a filename field that would update as a user copied
and renamed the file. Recently, the filename has not been
updating. F9 works, but you have to unprotect and resave the
document, and when tested, also does not change the filename
when renamed to a new file. Also found a macro which works as
F9 does. To do these steps would be like re-inventing the
wheel. The purpose of this form was to make it user-proof and
setup up general forms for each client we have - all a user
needed to do was fill in specific info, such as account amounts,
and the form would update the filename and retain the basic
client info. Did Microsoft change something? And how can I get
my nice little feature back? Any help will be greatly
appreciated. Thanks!






  #11   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor[_4_] Graham Mayor[_4_] is offline
external usenet poster
 
Posts: 9
Default Automatic Filename Update

Don't worry too much about the modules. If it works, it is probably fine
where it is.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"dp" wrote in message
...
Using Word 2007, windows XP. I copied this macro and started to install.
I
copied it fine but got mixed up with the Modules and projects described in
your "Installing Macros From Listings" so closed the window. Tested
anyway
and it seems to work - what problems am I causing by not getting it in the
right project / module. Beginning to think I'\'m better off manually
updating the field.


"Graham Mayor" wrote:

A minor addition to the macro will ensure that it always shows the
correct
filename

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
'****************
ActiveDocument.Save
'****************
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Putting the filename in the body of the document would have required
each file to be edited, or recreated, individually. BUT THE SECOND
OPTION, adding the macro to the toolbar - WORKS PERFECTLY EVEN IN
PROTECTED DOCUMENTS! Created the macro, added it to the toolbar, and
tested it. Opened different protected files which had filename
fieldcodes in footers, changed the other data that I wanted to
change, hit the macro button on the toolbar, instant filename change
in the protected documents' footers. Beautiful! Thank you ever so
much!

"Deb" wrote:

Thanks, Graham. It's funny - got the batch code from your site
yesterday, but not the additional protect/unprotect code. Cute
kitties you have on there. I will try each of the things offered in
the posts from you and Jay. Will add to this post with what actually
worked best. Thanks again!

"Graham Mayor" wrote:

If you put the filename field in the body of the document rather
than the footer and check the calculate on exit check box of one of
the fields that you will tab out of, the field will be updated.
or
You could add an update macro to the toolbar

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub

Batch macros will work on protected forms -
http://www.gmayor.com/batch_replace.htm provided the extra code to
unlock the forms where required is included. eg

Dim bProtected As Boolean
Dim sPassword As String
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Well....grrrrrrrr.... Thank you for responding so quickly. Macros
are not working within the documents - the option is greyed out
due I suppose to the forms being protected. I found another macro
that will change text in batches, and since the filename changes
would for the most part be the fiscal year, do you think that
would work? Would a macro for changing text in batches of files
work if the files are protected forms? I really, truly,
absolutely, do not want to have to update each and every file
individually. And whatever happened to the adage, 'if it ain't
broke, don't fix it'??? Hope you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is
unbelievably bogus -- but using a series of macros is the only way
to avoid needing manual updating. Besides the AutoOpen macro shown
in the KB article, you would also need one that intercepts the
Save As command and saves, updates the field, and saves again
(the first save changes the name of the file, but updating the
field "dirties" the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb
wrote:

A few years ago, I created a protected form which has a footer
containing a filename field that would update as a user copied
and renamed the file. Recently, the filename has not been
updating. F9 works, but you have to unprotect and resave the
document, and when tested, also does not change the filename
when renamed to a new file. Also found a macro which works as
F9 does. To do these steps would be like re-inventing the
wheel. The purpose of this form was to make it user-proof and
setup up general forms for each client we have - all a user
needed to do was fill in specific info, such as account amounts,
and the form would update the filename and retain the basic
client info. Did Microsoft change something? And how can I get
my nice little feature back? Any help will be greatly
appreciated. Thanks!






  #12   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor[_4_] Graham Mayor[_4_] is offline
external usenet poster
 
Posts: 9
Default Automatic Filename Update

Don't worry too much about the modules. If it works, it is probably fine
where it is.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"dp" wrote in message
...
Using Word 2007, windows XP. I copied this macro and started to install.
I
copied it fine but got mixed up with the Modules and projects described in
your "Installing Macros From Listings" so closed the window. Tested
anyway
and it seems to work - what problems am I causing by not getting it in the
right project / module. Beginning to think I'\'m better off manually
updating the field.


"Graham Mayor" wrote:

A minor addition to the macro will ensure that it always shows the
correct
filename

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
'****************
ActiveDocument.Save
'****************
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Putting the filename in the body of the document would have required
each file to be edited, or recreated, individually. BUT THE SECOND
OPTION, adding the macro to the toolbar - WORKS PERFECTLY EVEN IN
PROTECTED DOCUMENTS! Created the macro, added it to the toolbar, and
tested it. Opened different protected files which had filename
fieldcodes in footers, changed the other data that I wanted to
change, hit the macro button on the toolbar, instant filename change
in the protected documents' footers. Beautiful! Thank you ever so
much!

"Deb" wrote:

Thanks, Graham. It's funny - got the batch code from your site
yesterday, but not the additional protect/unprotect code. Cute
kitties you have on there. I will try each of the things offered in
the posts from you and Jay. Will add to this post with what actually
worked best. Thanks again!

"Graham Mayor" wrote:

If you put the filename field in the body of the document rather
than the footer and check the calculate on exit check box of one of
the fields that you will tab out of, the field will be updated.
or
You could add an update macro to the toolbar

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub

Batch macros will work on protected forms -
http://www.gmayor.com/batch_replace.htm provided the extra code to
unlock the forms where required is included. eg

Dim bProtected As Boolean
Dim sPassword As String
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Well....grrrrrrrr.... Thank you for responding so quickly. Macros
are not working within the documents - the option is greyed out
due I suppose to the forms being protected. I found another macro
that will change text in batches, and since the filename changes
would for the most part be the fiscal year, do you think that
would work? Would a macro for changing text in batches of files
work if the files are protected forms? I really, truly,
absolutely, do not want to have to update each and every file
individually. And whatever happened to the adage, 'if it ain't
broke, don't fix it'??? Hope you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is
unbelievably bogus -- but using a series of macros is the only way
to avoid needing manual updating. Besides the AutoOpen macro shown
in the KB article, you would also need one that intercepts the
Save As command and saves, updates the field, and saves again
(the first save changes the name of the file, but updating the
field "dirties" the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb
wrote:

A few years ago, I created a protected form which has a footer
containing a filename field that would update as a user copied
and renamed the file. Recently, the filename has not been
updating. F9 works, but you have to unprotect and resave the
document, and when tested, also does not change the filename
when renamed to a new file. Also found a macro which works as
F9 does. To do these steps would be like re-inventing the
wheel. The purpose of this form was to make it user-proof and
setup up general forms for each client we have - all a user
needed to do was fill in specific info, such as account amounts,
and the form would update the filename and retain the basic
client info. Did Microsoft change something? And how can I get
my nice little feature back? Any help will be greatly
appreciated. Thanks!






  #13   Report Post  
Posted to microsoft.public.word.docmanagement
DP DP is offline
external usenet poster
 
Posts: 162
Default Automatic Filename Update

Thank you

"Graham Mayor" wrote:

Don't worry too much about the modules. If it works, it is probably fine
where it is.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"dp" wrote in message
...
Using Word 2007, windows XP. I copied this macro and started to install.
I
copied it fine but got mixed up with the Modules and projects described in
your "Installing Macros From Listings" so closed the window. Tested
anyway
and it seems to work - what problems am I causing by not getting it in the
right project / module. Beginning to think I'\'m better off manually
updating the field.


"Graham Mayor" wrote:

A minor addition to the macro will ensure that it always shows the
correct
filename

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
'****************
ActiveDocument.Save
'****************
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Putting the filename in the body of the document would have required
each file to be edited, or recreated, individually. BUT THE SECOND
OPTION, adding the macro to the toolbar - WORKS PERFECTLY EVEN IN
PROTECTED DOCUMENTS! Created the macro, added it to the toolbar, and
tested it. Opened different protected files which had filename
fieldcodes in footers, changed the other data that I wanted to
change, hit the macro button on the toolbar, instant filename change
in the protected documents' footers. Beautiful! Thank you ever so
much!

"Deb" wrote:

Thanks, Graham. It's funny - got the batch code from your site
yesterday, but not the additional protect/unprotect code. Cute
kitties you have on there. I will try each of the things offered in
the posts from you and Jay. Will add to this post with what actually
worked best. Thanks again!

"Graham Mayor" wrote:

If you put the filename field in the body of the document rather
than the footer and check the calculate on exit check box of one of
the fields that you will tab out of, the field will be updated.
or
You could add an update macro to the toolbar

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub

Batch macros will work on protected forms -
http://www.gmayor.com/batch_replace.htm provided the extra code to
unlock the forms where required is included. eg

Dim bProtected As Boolean
Dim sPassword As String
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Well....grrrrrrrr.... Thank you for responding so quickly. Macros
are not working within the documents - the option is greyed out
due I suppose to the forms being protected. I found another macro
that will change text in batches, and since the filename changes
would for the most part be the fiscal year, do you think that
would work? Would a macro for changing text in batches of files
work if the files are protected forms? I really, truly,
absolutely, do not want to have to update each and every file
individually. And whatever happened to the adage, 'if it ain't
broke, don't fix it'??? Hope you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is
unbelievably bogus -- but using a series of macros is the only way
to avoid needing manual updating. Besides the AutoOpen macro shown
in the KB article, you would also need one that intercepts the
Save As command and saves, updates the field, and saves again
(the first save changes the name of the file, but updating the
field "dirties" the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb
wrote:

A few years ago, I created a protected form which has a footer
containing a filename field that would update as a user copied
and renamed the file. Recently, the filename has not been
updating. F9 works, but you have to unprotect and resave the
document, and when tested, also does not change the filename
when renamed to a new file. Also found a macro which works as
F9 does. To do these steps would be like re-inventing the
wheel. The purpose of this form was to make it user-proof and
setup up general forms for each client we have - all a user
needed to do was fill in specific info, such as account amounts,
and the form would update the filename and retain the basic
client info. Did Microsoft change something? And how can I get
my nice little feature back? Any help will be greatly
appreciated. Thanks!





.

  #14   Report Post  
Posted to microsoft.public.word.docmanagement
DP DP is offline
external usenet poster
 
Posts: 162
Default Automatic Filename Update

Thank you

"Graham Mayor" wrote:

Don't worry too much about the modules. If it works, it is probably fine
where it is.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"dp" wrote in message
...
Using Word 2007, windows XP. I copied this macro and started to install.
I
copied it fine but got mixed up with the Modules and projects described in
your "Installing Macros From Listings" so closed the window. Tested
anyway
and it seems to work - what problems am I causing by not getting it in the
right project / module. Beginning to think I'\'m better off manually
updating the field.


"Graham Mayor" wrote:

A minor addition to the macro will ensure that it always shows the
correct
filename

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
'****************
ActiveDocument.Save
'****************
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Putting the filename in the body of the document would have required
each file to be edited, or recreated, individually. BUT THE SECOND
OPTION, adding the macro to the toolbar - WORKS PERFECTLY EVEN IN
PROTECTED DOCUMENTS! Created the macro, added it to the toolbar, and
tested it. Opened different protected files which had filename
fieldcodes in footers, changed the other data that I wanted to
change, hit the macro button on the toolbar, instant filename change
in the protected documents' footers. Beautiful! Thank you ever so
much!

"Deb" wrote:

Thanks, Graham. It's funny - got the batch code from your site
yesterday, but not the additional protect/unprotect code. Cute
kitties you have on there. I will try each of the things offered in
the posts from you and Jay. Will add to this post with what actually
worked best. Thanks again!

"Graham Mayor" wrote:

If you put the filename field in the body of the document rather
than the footer and check the calculate on exit check box of one of
the fields that you will tab out of, the field will be updated.
or
You could add an update macro to the toolbar

Sub UnpdateFieldInFooter()
Dim oField As Field
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
End If
Next oFooter
Next oSection
End Sub

Batch macros will work on protected forms -
http://www.gmayor.com/batch_replace.htm provided the extra code to
unlock the forms where required is included. eg

Dim bProtected As Boolean
Dim sPassword As String
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Deb wrote:
Well....grrrrrrrr.... Thank you for responding so quickly. Macros
are not working within the documents - the option is greyed out
due I suppose to the forms being protected. I found another macro
that will change text in batches, and since the filename changes
would for the most part be the fiscal year, do you think that
would work? Would a macro for changing text in batches of files
work if the files are protected forms? I really, truly,
absolutely, do not want to have to update each and every file
individually. And whatever happened to the adage, 'if it ain't
broke, don't fix it'??? Hope you're having a great day!

"Jay Freedman" wrote:

That behavior changed in Word 2002, as described in
http://support.microsoft.com/?kbid=832897.

I sympathize -- especially as the stated reason for the change is
unbelievably bogus -- but using a series of macros is the only way
to avoid needing manual updating. Besides the AutoOpen macro shown
in the KB article, you would also need one that intercepts the
Save As command and saves, updates the field, and saves again
(the first save changes the name of the file, but updating the
field "dirties" the document and makes another save necessary).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 24 Mar 2009 16:52:01 -0700, Deb
wrote:

A few years ago, I created a protected form which has a footer
containing a filename field that would update as a user copied
and renamed the file. Recently, the filename has not been
updating. F9 works, but you have to unprotect and resave the
document, and when tested, also does not change the filename
when renamed to a new file. Also found a macro which works as
F9 does. To do these steps would be like re-inventing the
wheel. The purpose of this form was to make it user-proof and
setup up general forms for each client we have - all a user
needed to do was fill in specific info, such as account amounts,
and the form would update the filename and retain the basic
client info. Did Microsoft change something? And how can I get
my nice little feature back? Any help will be greatly
appreciated. Thanks!





.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I get the filename in the footer to update automatically? vnathan Microsoft Word Help 1 October 22nd 08 03:44 AM
Save As - automatic fillin of new filename Sammy Microsoft Word Help 1 August 22nd 07 11:33 PM
Filename in Footer - update automatically? SteveK New Users 5 June 25th 06 02:17 PM
How can Word update the linked filename for Shape object automatic 大熊 Microsoft Word Help 0 November 18th 05 03:59 AM
How do I get the filename to auto update? Nikkit72 Microsoft Word Help 10 May 6th 05 03:29 PM


All times are GMT +1. The time now is 05:28 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"