Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

Delete 'filename and path' field from footer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leila - 07 Apr 2005 21:47 GMT
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
Charles Kenyon - 08 Apr 2005 01:41 GMT
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.
Signature

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.

> 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.
[quoted text clipped - 20 lines]
>
>    End If
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.