Ron
Tue Feb 22 16:06:49 CST 2005
Excellent! That's exactly what I was looking for.
My mistake was to assume that document.fields() returns all the fields in
the document...
Thanks a lot for your help.
--
______________________
Life is a dream, make it real.
"Jezebel" <warcrimes@whitehouse.gov> wrote in message
news:O1q1oyRGFHA.524@TK2MSFTNGP14.phx.gbl...
> The document.Fields() collection includes only the fields in the body of
> the document. To get all fields, wherever they occur, you need to iterate
> all the SotryRanges separately --
>
> Dim pRange as Word.Range
> For each pRange in objDoc.StoryRanges
> Do
> Do until pRange.Fields.Count = 0
> pRange.Fields(1).Delete
> Loop
> set pRange = pRange.Next
> Loop until pRange is nothing
> Next
>
>
>
>
>
> "Ron John" <anglas@gmailNOSPAM.com> wrote in message
> news:cvg21n$979$1@news.freedom2surf.net...
>> Thanks for the info, I have sorted out that bit already.
>> Now I have another question: how can I remove all the auto fields in the
>> document.
>> The code below doesn't work in all occasions. In some instances, after
>> running that code, the document still contains some auto fields. Most of
>> the time they are at the end of the document, usually in headers and
>> footers. Any ideas why that happens?
>>
>> Set objWord = New Word.Application
>> Set objDoc = objWord.Documents.Open("C:\1.doc", False, True, , "")
>> With objDoc
>> For i = 1 To .Fields.Count
>> .Fields(i).Delete
>> Next i
>> .SaveAs "C:\1.txt", wdFormatText
>> .Close wdDoNotSaveChanges
>> End With
>>
>> --
>> ______________________
>> Life is a dream, make it real.
>> "Jay Freedman" <jay.freedman@verizon.net> wrote in message
>> news:3v7l11le6gnm34c9hm1h7umjioedqhhq2b@4ax.com...
>>> They're documented at
>>>
http://word.mvps.org/FAQs/TblsFldsFms/AddinFields.htm instead. :-)
>>>
>>> --
>>> Regards,
>>> Jay Freedman
>>> Microsoft Word MVP FAQ:
http://word.mvps.org
>>>
>>> On Mon, 21 Feb 2005 07:49:09 +1100, "Jezebel"
>>> <warcrimes@whitehouse.gov> wrote:
>>>
>>>>As a general answer, of course, it's quite right. But AddIn fields are
>>>>not
>>>>documented in Help.
>>>>
>>>>
>>>>
>>>>"Jay Freedman" <JayFreedman@discussions.microsoft.com> wrote in message
>>>>news:0B9E06B1-CD2F-416F-9A60-A5AC50067B40@microsoft.com...
>>>>> Hi Ron,
>>>>>
>>>>> When you peel off the wdField prefix, what's left corresponds to the
>>>>> keyword
>>>>> that starts the field code of the field you'll get when you use
>>>>> Fields.Add.
>>>>>
>>>>> Ask the regular Word help file for "Field code <type>" for that
>>>>> <type> --
>>>>> for example, ask about "Field code AddIn" or "Field code Advance".
>>>>> You'll
>>>>> get
>>>>> a list of the other information that can be included in that field
>>>>> code,
>>>>> such
>>>>> as a bookmark name, a file name, or various switches.
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Jay Freedman
>>>>>
>>>>> "Ron John" wrote:
>>>>>
>>>>>> Where can I find an exhaustive explanation to the meaning
>>>>>> of wdFieldType values? As it usually happens with VBA
>>>>>> help, a complete list of values is presented
>>>>>> (wdFieldAddIn, wdFieldAdvance...), but there's no way to
>>>>>> know how those constants work.
>>>>>> I've searched in WordBasic help too, trying to find some
>>>>>> kind of analogy, but that didn't help me at all.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>>
>>>>>> --
>>>>>> ______________________
>>>>>> Life is a dream, make it real.
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>
>>
>>
>
>