Delete 'filename and path' field from footer

L

Leila

Hi There, I want to create a macro which deletes the field (File name and
Path- FILENAME \p ) from footer and then insert my customized footer.
I don’t know how to delete this fields I tried many different ways but none
work properly please help. thanks!
----------
If WordBasic.ViewFooter() = 0 Then
'Go to footer area
WordBasic.ViewFooter
End If

'This will clear the contents of the previous Footer
WordBasic.EditSelectAll
WordBasic.EditCut

-------------
' this doesnt work ??????
FooterAField = NormalTemplate.AutoTextEntries("Filename and path")

If FooterAField = 1 Then
'Marker exists, Delete it
NormalTemplate.AutoTextEntries("Filename and path").Delete

End If
 
C

Charles Kenyon

Which version of Word? Word Basic was last used integrally in Word 95. You
should be coding in vba if you are working with a more recent version of
Word.

I take it that your customized footer is stored as an AutoText entry?

Are you trying to delete the entire footer or just the field?

You'll need to cycle through the sectionscollection and the footers
collection for each section.

The following macros reaches fields in the headers/footers for updating or
locking. It tests for the nature of the field. You may be able to adopt it
to select said field and replace it with your custom material.

Sub RefFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 15 November 2001
' repaired by Jezebel
' All Story Field Updater - Ref fields
Dim oField As Field
Dim oStory As Range
' On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
Do
For Each oField In oStory.Fields
If oField.Type = wdFieldRef Then
oField.Update
End If
Next oField
Set oStory = oStory.Next
Loop Until oStory Is Nothing
Next oStory
End Sub
Private Sub MergeFieldLockAllStory()
' Written by Charles Kyle Kenyon 1 April 2005
'
' All Story Field Locker - Merge fields
Dim oField As Field
Dim oStory As Range
' On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
Do
For Each oField In oStory.Fields
If oField.Type = wdFieldMergeField Then
oField.Lock
End If
Next oField
Set oStory = oStory.Next
Loop Until oStory Is Nothing
Next oStory
End Sub

Private Sub TOCFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 15 November 2001
' repaired by Jezebel
' All Story Field Updater - TOC fields
Dim oField As Field
Dim oStory As Range
' On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
Do
For Each oField In oStory.Fields
If oField.Type = wdFieldTOC Then
oField.Update
End If
Next oField
Set oStory = oStory.Next
Loop Until oStory Is Nothing
Next oStory
End Sub
Private Sub TOCFieldUpdate()
' Written by Charles Kyle Kenyon 27 January 2005
' Field Updater - TOC fields
Dim oField As Field
On Error Resume Next
For Each oField In ActiveDocument.Fields
If oField.Type = wdFieldTOC Then
oField.Update
End If
Next oField
End Sub

Hope this helps.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

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

Top