Melinda
Fri Sep 14 13:59:10 CDT 2007
Thanks Jay!
That was exactly what I needed.
You are correct, I had a paragraph return at the end of each line, so
deleting the paragraph is fine.
Thanks again.
Melinda
"Jay Freedman" <jay.freedman@verizon.net> wrote in message
news:O72iwEu9HHA.2140@TK2MSFTNGP06.phx.gbl...
> This macro will delete the entire paragraph (note: Word doesn't know much
> about "lines", it's geared toward paragraphs, but in this case I suspect
> they're the same thing) if the form field contains its default text
> (whatever that is, whether "Ingredient" or any other text, or five
> nonbreaking spaces if the default isn't set).
>
> Sub CleanUp()
> Dim ffld As FormField
>
> If ActiveDocument.ProtectionType <> wdNoProtection Then
> ActiveDocument.Unprotect
> End If
>
> For Each ffld In ActiveDocument.FormFields
> With ffld
> If .Type = wdFieldFormTextInput Then
> If .Result = .TextInput.Default Then
> .Range.Paragraphs(1).Range.Delete
> End If
> End If
> End With
> Next
>
> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
> noreset:=True
> End Sub
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ:
http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup
> so all may benefit.
>
> Melinda Chase wrote:
>> Hello,
>> I have a template that is used to create recipes for upload to a
>> website. The person typing in the recipes is not very computer
>> literate, so I made a form with fields for him to fill in with
>> ingredients. The fields' default text is "Ingredient". I put in 15
>> lines for ingredients. Obviously, not all recipes have that many
>> ingredients. I'd like to write a macro to delete the lines that
>> don't have ingredients in them, i.e., they say "Ingredient" in the
>> form field. To make it more complicated, I'd like to delete the
>> entire line, not just the form field. Is there a way to do this? I've
>> tried a find and replace, but that doesn't seem to work with
>> form fields. Anyone have any guidance? Thanks!
>> Melinda
>
>