as well as file and path name field. These fields are located in the first
cell of a one row table located in every footer in every section (also first
page footer exists). How can I delete all of these fields in a macro?

I appreciate any help regarding this.

Using Word 2003
--
CLG

Re: Macro to remove date field, page number field by Greg

Greg
Sat Feb 11 18:20:56 CST 2006

The first macro will delete all fields in a document. The second should do
what you have specifically asked for.

Sub DeleteAllFields()
Dim pRange As Word.Range
For Each pRange In ActiveDocument.StoryRanges
Do
With pRange.Fields
While .Count > 0
.Item(1).Delete
Wend
End With
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
End Sub
Sub DeleteSelectedFields()
Dim pRange As Word.Range
Dim oFld As Field
For Each pRange In ActiveDocument.StoryRanges
Select Case pRange.StoryType
Case wdFirstPageFooterStory, _
wdPrimaryFooterStory, wdEvenPagesFooterStory
For Each oFld In pRange.Fields
Select Case oFld.Type
Case wdFieldPage, wdFieldDate, _
wdFieldFileName
oFld.Delete
Case Else
'Do Nothing
End Select
Next
Case Else
'Do nothing
End Select
Next
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Legal Learning wrote:
> as well as file and path name field. These fields are located in the
> first cell of a one row table located in every footer in every
> section (also first page footer exists). How can I delete all of
> these fields in a macro?
>
> I appreciate any help regarding this.
>
> Using Word 2003



Re: Macro to remove date field, page number field by Helmut

Helmut
Sat Feb 11 18:31:32 CST 2006

Hi,

just to get you going:

http://word.mvps.org/faqs/customization/ReplaceAnywhere.htm

Then, you may have to loop through all the fields
in the storyrange and check their type.

See help for:
type property as it applies to the field, formfield [...] objects.

IMHO, there is no
"file and path name" field.

Only a field "filename" with an additional switch.

FILENAME \p \* MERGEFORMAT

as opposed to

FILENAME \* MERGEFORMAT

So you would have to check the field code.

You may try to use goto as well,
but I wouldn't recommend it,
as it seems to need the selection
for finding out, whether the execution was successfull.


HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Re: Macro to remove date field, page number field by LegalLearning

LegalLearning
Sun Feb 12 11:48:26 CST 2006

Thanks very much. This was very helpful. I will tweak it to delete the time
field and figure out how to not delete the second page number field (which
they want to keep). You are very good!
--
CLG


"Greg Maxey" wrote:

> The first macro will delete all fields in a document. The second should do
> what you have specifically asked for.
>
> Sub DeleteAllFields()
> Dim pRange As Word.Range
> For Each pRange In ActiveDocument.StoryRanges
> Do
> With pRange.Fields
> While .Count > 0
> .Item(1).Delete
> Wend
> End With
> Set pRange = pRange.NextStoryRange
> Loop Until pRange Is Nothing
> Next
> End Sub
> Sub DeleteSelectedFields()
> Dim pRange As Word.Range
> Dim oFld As Field
> For Each pRange In ActiveDocument.StoryRanges
> Select Case pRange.StoryType
> Case wdFirstPageFooterStory, _
> wdPrimaryFooterStory, wdEvenPagesFooterStory
> For Each oFld In pRange.Fields
> Select Case oFld.Type
> Case wdFieldPage, wdFieldDate, _
> wdFieldFileName
> oFld.Delete
> Case Else
> 'Do Nothing
> End Select
> Next
> Case Else
> 'Do nothing
> End Select
> Next
> End Sub
>
> --
> Greg Maxey/Word MVP
> See:
> http://gregmaxey.mvps.org/word_tips.htm
> For some helpful tips using Word.
>
>
> Legal Learning wrote:
> > as well as file and path name field. These fields are located in the
> > first cell of a one row table located in every footer in every
> > section (also first page footer exists). How can I delete all of
> > these fields in a macro?
> >
> > I appreciate any help regarding this.
> >
> > Using Word 2003
>
>
>

Re: Macro to remove date field, page number field by LegalLearning

LegalLearning
Sun Feb 12 11:49:27 CST 2006

Thank you very much Helmut! Hope you are getting as much snow as we are in
Vail Colorado! Take care
--
CLG


"Helmut Weber" wrote:

> Hi,
>
> just to get you going:
>
> http://word.mvps.org/faqs/customization/ReplaceAnywhere.htm
>
> Then, you may have to loop through all the fields
> in the storyrange and check their type.
>
> See help for:
> type property as it applies to the field, formfield [...] objects.
>
> IMHO, there is no
> "file and path name" field.
>
> Only a field "filename" with an additional switch.
>
> FILENAME \p \* MERGEFORMAT
>
> as opposed to
>
> FILENAME \* MERGEFORMAT
>
> So you would have to check the field code.
>
> You may try to use goto as well,
> but I wouldn't recommend it,
> as it seems to need the selection
> for finding out, whether the execution was successfull.
>
>
> HTH
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
>

Re: Macro to remove date field, page number field by LegalLearning

LegalLearning
Sun Feb 12 12:39:27 CST 2006

I am now having trouble getting the page number back into the second cell of
a one row table in the footer. This is with as many sections as there might
be in the document but only on wdPrimaryFooterStory. Can you help me with
that?
--
CLG


"Greg Maxey" wrote:

> The first macro will delete all fields in a document. The second should do
> what you have specifically asked for.
>
> Sub DeleteAllFields()
> Dim pRange As Word.Range
> For Each pRange In ActiveDocument.StoryRanges
> Do
> With pRange.Fields
> While .Count > 0
> .Item(1).Delete
> Wend
> End With
> Set pRange = pRange.NextStoryRange
> Loop Until pRange Is Nothing
> Next
> End Sub
> Sub DeleteSelectedFields()
> Dim pRange As Word.Range
> Dim oFld As Field
> For Each pRange In ActiveDocument.StoryRanges
> Select Case pRange.StoryType
> Case wdFirstPageFooterStory, _
> wdPrimaryFooterStory, wdEvenPagesFooterStory
> For Each oFld In pRange.Fields
> Select Case oFld.Type
> Case wdFieldPage, wdFieldDate, _
> wdFieldFileName
> oFld.Delete
> Case Else
> 'Do Nothing
> End Select
> Next
> Case Else
> 'Do nothing
> End Select
> Next
> End Sub
>
> --
> Greg Maxey/Word MVP
> See:
> http://gregmaxey.mvps.org/word_tips.htm
> For some helpful tips using Word.
>
>
> Legal Learning wrote:
> > as well as file and path name field. These fields are located in the
> > first cell of a one row table located in every footer in every
> > section (also first page footer exists). How can I delete all of
> > these fields in a macro?
> >
> > I appreciate any help regarding this.
> >
> > Using Word 2003
>
>
>