From: celia on
Hi,
I'm having this problem.
DOCPROPERTY"WFWProfile" \* MERGEFORMAT 1Error! Bookmark not defined.

Wanted to delete it but can't.

What am i suppose to do?

Thanks.


"Lene Fredborg" wrote:

> Below is a revised version of your code. The macro should do what you want.
> It checks all fields but only deletes fields of the type DocProperty that
> contains the string "SWDocID" in the field code.
>
> Sub DeleteDocPropertyInFooters()
> Dim oSec As Section
> Dim oFoot As HeaderFooter
> Dim oField As Field
>
> For Each oSec In ActiveDocument.Sections
>
> For Each oFoot In oSec.Footers
> If oFoot.Exists Then
> For Each oField In oFoot.Range.Fields
> If oField.Type = wdFieldDocProperty Then
> If InStr(1, oField.Code.Text, "SWDocID") > 0 Then
> oField.Delete
> End If
> End If
> Next oField
> End If
> Next oFoot
> Next oSec
> End Sub
>
> --
> Regards
> Lene Fredborg
> DocTools - Denmark
> www.thedoctools.com
> Document automation - add-ins, macros and templates for Microsoft Word
>
>
> "jerem" wrote:
>
> > I would like to use the code below to delete only a certain field code
> > appearing in each Section's footer. I don't want the page numbering field
> > codes deleted, I just want the document ID # deleted. When I use the Find
> > stipulating a field code (^d) it finds any and every field code including
> > page number field codes. Is there any way to stipulate a specific field code?
> >
> > The code below works wonderfully for deleting all footers but I want to
> > replace the
> > statement of Then oFoot.Range.Delete with something like this: find
> > specifically the document ID#, which appears in the document in this form: {
> > DOCPROPERTY "SWDocID" \*MERGEFORMAT }, and then delete it, but I don't know
> > how to be field code specific.
> >
> > Any help would be appreciated.
> >
> > Sub DeleteFooters()
> > Dim oSec As Section
> > Dim oFoot As HeaderFooter
> >
> > For Each oSec In ActiveDocument.Sections
> > For Each oFoot In oSec.Footers
> > If oFoot.Exists Then oFoot.Range.Delete
> > Next oFoot
> > Next oSec
> > End Sub
> >
From: Doug Robbins - Word MVP on
Can we have some more information about what you are trying to do? What you
have tried? What happens when you select it and press delete?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"celia" <celia(a)discussions.microsoft.com> wrote in message
news:7F0D54B4-2C63-4CD5-9854-CE99C21F9B77(a)microsoft.com...
> Hi,
> I'm having this problem.
> DOCPROPERTY"WFWProfile" \* MERGEFORMAT 1Error! Bookmark not defined.
>
> Wanted to delete it but can't.
>
> What am i suppose to do?
>
> Thanks.
>
>
> "Lene Fredborg" wrote:
>
>> Below is a revised version of your code. The macro should do what you
>> want.
>> It checks all fields but only deletes fields of the type DocProperty that
>> contains the string "SWDocID" in the field code.
>>
>> Sub DeleteDocPropertyInFooters()
>> Dim oSec As Section
>> Dim oFoot As HeaderFooter
>> Dim oField As Field
>>
>> For Each oSec In ActiveDocument.Sections
>>
>> For Each oFoot In oSec.Footers
>> If oFoot.Exists Then
>> For Each oField In oFoot.Range.Fields
>> If oField.Type = wdFieldDocProperty Then
>> If InStr(1, oField.Code.Text, "SWDocID") > 0 Then
>> oField.Delete
>> End If
>> End If
>> Next oField
>> End If
>> Next oFoot
>> Next oSec
>> End Sub
>>
>> --
>> Regards
>> Lene Fredborg
>> DocTools - Denmark
>> www.thedoctools.com
>> Document automation - add-ins, macros and templates for Microsoft Word
>>
>>
>> "jerem" wrote:
>>
>> > I would like to use the code below to delete only a certain field code
>> > appearing in each Section's footer. I don't want the page numbering
>> > field
>> > codes deleted, I just want the document ID # deleted. When I use the
>> > Find
>> > stipulating a field code (^d) it finds any and every field code
>> > including
>> > page number field codes. Is there any way to stipulate a specific
>> > field code?
>> >
>> > The code below works wonderfully for deleting all footers but I want to
>> > replace the
>> > statement of Then oFoot.Range.Delete with something like this: find
>> > specifically the document ID#, which appears in the document in this
>> > form: {
>> > DOCPROPERTY "SWDocID" \*MERGEFORMAT }, and then delete it, but I don't
>> > know
>> > how to be field code specific.
>> >
>> > Any help would be appreciated.
>> >
>> > Sub DeleteFooters()
>> > Dim oSec As Section
>> > Dim oFoot As HeaderFooter
>> >
>> > For Each oSec In ActiveDocument.Sections
>> > For Each oFoot In oSec.Footers
>> > If oFoot.Exists Then oFoot.Range.Delete
>> > Next oFoot
>> > Next oSec
>> > End Sub
>> >