From: JFREE223 on
Graham Mayor stated that the logic below would insert an intitial field at
the place of the cursor. Is there a way to remove the intitial cursor field
entry using the logic below????

Sub WageProtect()
'
' WageProtect Macro
'
' If document is protected, Unprotect it.
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="fixstyles"
End If
' Insert a Field
ActiveDocument.FormFields.Add _
Range:=Selection.Range, _
Type:=wdFieldFormTextInput
With Selection.Find
Do While .Execute(findText:="___________", _
Wrap:=wdFindContinue)
Set oRng = Selection.Range
oRng.FormFields.Add Range:=oRng, _
Type:=wdFieldFormTextInput
Loop
End With
' Insert a Field
ActiveDocument.FormFields.Add _
Range:=Selection.Range, _
Type:=wdFieldFormTextInput
With Selection.Find
Do While .Execute(findText:="_______-__-_____", _
Wrap:=wdFindContinue)
Set oRng = Selection.Range
oRng.FormFields.Add Range:=oRng, _
Type:=wdFieldFormTextInput
Loop
End With

' ReProtect the document.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
Password:="fixstyles", NoReset:=True
End If
End Sub

"Graham Mayor" wrote:

> OK - the following will insert a form field at the cursor (as your original)
> and replace each instance of *** in the main document with a text form
> field, without going into an endless loop. However it would be probably be
> better to identify the ranges where the form fields are intended to go
> (multiple tables shouldn't be an issue) and insert the form fields in those
> ranges.
>
> Sub WageProtect()
> '
> ' WageProtect Macro
> '
> ' If document is protected, Unprotect it.
> If ActiveDocument.ProtectionType <> wdNoProtection Then
> ActiveDocument.Unprotect Password:="fixstyles"
> End If
> ' Insert a Field
> ActiveDocument.FormFields.Add _
> Range:=Selection.Range, _
> Type:=wdFieldFormTextInput
> With Selection.Find
> Do While .Execute(findText:="***", _
> Wrap:=wdFindContinue)
> Set oRng = Selection.Range
> oRng.FormFields.Add Range:=oRng, _
> Type:=wdFieldFormTextInput
> Loop
> End With
> ' ReProtect the document.
> If ActiveDocument.ProtectionType = wdNoProtection Then
> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
> Password:="fixstyles", NoReset:=True
> End If
> End Sub
>
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - Word MVP
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
>
> JFREE223 wrote:
> > Thanks, it would work if we only had one table and it is a better
> > approach for what I explained. DEFINITELY needed the reprotect code
> > inserted correctly, so thanks.
> >
> > We have to search for this in multiple tables and areas in the
> > document. Text fields have to be inserted where we need a signature,
> > revision to monetary values, dates, etc...
> >
> >
> >
> > "Graham Mayor" wrote:
> >
> >> It could be much simpler! And you haven't reset the password.
> >> Assuming table 1 in the document and that you have a header row.
> >>
> >> Sub WageProtect()
> >> '
> >> ' WageProtect Macro
> >> Dim oTable As Table
> >> Set oTable = ActiveDocument.Tables(1)
> >> ' If document is protected, Unprotect it.
> >> If ActiveDocument.ProtectionType <> wdNoProtection Then
> >> ActiveDocument.Unprotect Password:="fixstyles"
> >> End If
> >>
> >> For i = 2 To oTable.Rows.Count
> >> ' Insert a Field
> >> ActiveDocument.FormFields.Add _
> >> Range:=oTable.Cell(i, 3).Range, _
> >> Type:=wdFieldFormTextInput
> >> Next i
> >>
> >> ' ReProtect the document.
> >> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
> >> Password:="fixstyles", _
> >> NoReset:=True
> >> End Sub
> >>
> >> --
> >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> >> Graham Mayor - Word MVP
> >>
> >> My web site www.gmayor.com
> >> Word MVP web site http://word.mvps.org
> >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> >>
> >>
> >>
> >> JFREE223 wrote:
> >>> Here is the logic if anybody needs it. This code is searching for
> >>> "***"
> >>>
> >>> Sub WageProtect()
> >>> '
> >>> ' WageProtect Macro
> >>> '
> >>> '
> >>>
> >>> ' If document is protected, Unprotect it.
> >>> If ActiveDocument.ProtectionType <> wdNoProtection Then
> >>> ActiveDocument.Unprotect Password:="fixstyles"
> >>> End If
> >>>
> >>> ' Insert a Field
> >>> ActiveDocument.FormFields.Add Range:=Selection.Range,
> >>> Type:=wdFieldFormTextInput
> >>>
> >>> Dim mySearchString As String
> >>> Dim x As Integer
> >>> x = 0
> >>>
> >>> mySearchString = "***"
> >>>
> >>> With Selection.Find
> >>> .Text = mySearchString
> >>> ' .Wrap = wdFindContinue
> >>> Do While Selection.Find.Execute = True
> >>> x = x + 1
> >>> Selection.FormFields.Add Range:=Selection.Range,
> >>> Type:=wdFieldFormTextInput
> >>> If x > 10000 Then MsgBox "Possible Endless Loop. The macro
> >>> has interrupted itself automatically to prevent freezing the
> >>> computer.": End Loop
> >>> End With
> >>>
> >>> ' ReProtect the document.
> >>> If ActiveDocument.ProtectionType = wdNoProtection Then
> >>> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
> >>> NoReset:=True
> >>> End If
> >>>
> >>> End Sub
> >>>
> >>>
> >>>
> >>>
> >>> "JFREE223" wrote:
> >>>
> >>>> I've got the code from 'Insert a Field and assign to button' from
> >>>> Sarah_Lecturer discussion, which seems to work great. The only
> >>>> thing I'm missing is being able to insert multiple text form fields
> >>>> instead of one. If I could highlight the columns in the table and
> >>>> insert all at once...great. If not, then I'd like it to identify
> >>>> '0' and insert text form field.
> >>>>
> >>>> "JFREE223" wrote:
> >>>>
> >>>>> Oops it ran out of space. the $3,000 and $3,050 go under New
> >>>>> Amount.
> >>>>>
> >>>>> "JFREE223" wrote:
> >>>>>
> >>>>>> Looking for a method to insert a text form field and protect a
> >>>>>> word doc in one click. Don't know if this is even possible. I
> >>>>>> have a document that is generated by an external system. It is
> >>>>>> populated with several rows of dates (monthly) and corresponding
> >>>>>> data. I need to find a method for protecting the whole document
> >>>>>> except for a 'column' beside the pre-populated data...on
> >>>>>> one-click if possible. The new amount column (not the header) in
> >>>>>> the table needs to be unprotected and enterable upon clicking.
> >>>>>> May not need a form field. If we could just protect date and
> >>>>>> Amount upon a click, that may be an option. Thanks in advance.
> >>>>>>
> >>>>>> example:
> >>>>>> Date (pre-populated) Amount (pre-populated)
> >>>>>> New Amount 1/1/2009 $2,200.00
> >>>>>> $3,000
> >>>>>> 12/31/2008 $2,200.00
> >>>>>> $3,050
>
>
>
From: Doug Robbins - Word MVP on
Remove or comment out the first instance (and possibly the second, depending
upon just what you want to achieve) of the following lines of code:

ActiveDocument.FormFields.Add _
Range:=Selection.Range, _
Type:=wdFieldFormTextInput


--
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

"JFREE223" <JFREE223(a)discussions.microsoft.com> wrote in message
news:733D40C7-7599-4016-9ED0-379C3D096479(a)microsoft.com...
> Graham Mayor stated that the logic below would insert an intitial field at
> the place of the cursor. Is there a way to remove the intitial cursor
> field
> entry using the logic below????
>
> Sub WageProtect()
> '
> ' WageProtect Macro
> '
> ' If document is protected, Unprotect it.
> If ActiveDocument.ProtectionType <> wdNoProtection Then
> ActiveDocument.Unprotect Password:="fixstyles"
> End If
> ' Insert a Field
> ActiveDocument.FormFields.Add _
> Range:=Selection.Range, _
> Type:=wdFieldFormTextInput
> With Selection.Find
> Do While .Execute(findText:="___________", _
> Wrap:=wdFindContinue)
> Set oRng = Selection.Range
> oRng.FormFields.Add Range:=oRng, _
> Type:=wdFieldFormTextInput
> Loop
> End With
> ' Insert a Field
> ActiveDocument.FormFields.Add _
> Range:=Selection.Range, _
> Type:=wdFieldFormTextInput
> With Selection.Find
> Do While .Execute(findText:="_______-__-_____", _
> Wrap:=wdFindContinue)
> Set oRng = Selection.Range
> oRng.FormFields.Add Range:=oRng, _
> Type:=wdFieldFormTextInput
> Loop
> End With
>
> ' ReProtect the document.
> If ActiveDocument.ProtectionType = wdNoProtection Then
> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
> Password:="fixstyles", NoReset:=True
> End If
> End Sub
>
> "Graham Mayor" wrote:
>
>> OK - the following will insert a form field at the cursor (as your
>> original)
>> and replace each instance of *** in the main document with a text form
>> field, without going into an endless loop. However it would be probably
>> be
>> better to identify the ranges where the form fields are intended to go
>> (multiple tables shouldn't be an issue) and insert the form fields in
>> those
>> ranges.
>>
>> Sub WageProtect()
>> '
>> ' WageProtect Macro
>> '
>> ' If document is protected, Unprotect it.
>> If ActiveDocument.ProtectionType <> wdNoProtection Then
>> ActiveDocument.Unprotect Password:="fixstyles"
>> End If
>> ' Insert a Field
>> ActiveDocument.FormFields.Add _
>> Range:=Selection.Range, _
>> Type:=wdFieldFormTextInput
>> With Selection.Find
>> Do While .Execute(findText:="***", _
>> Wrap:=wdFindContinue)
>> Set oRng = Selection.Range
>> oRng.FormFields.Add Range:=oRng, _
>> Type:=wdFieldFormTextInput
>> Loop
>> End With
>> ' ReProtect the document.
>> If ActiveDocument.ProtectionType = wdNoProtection Then
>> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
>> Password:="fixstyles", NoReset:=True
>> End If
>> End Sub
>>
>>
>> --
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> Graham Mayor - Word MVP
>>
>> My web site www.gmayor.com
>> Word MVP web site http://word.mvps.org
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>>
>>
>> JFREE223 wrote:
>> > Thanks, it would work if we only had one table and it is a better
>> > approach for what I explained. DEFINITELY needed the reprotect code
>> > inserted correctly, so thanks.
>> >
>> > We have to search for this in multiple tables and areas in the
>> > document. Text fields have to be inserted where we need a signature,
>> > revision to monetary values, dates, etc...
>> >
>> >
>> >
>> > "Graham Mayor" wrote:
>> >
>> >> It could be much simpler! And you haven't reset the password.
>> >> Assuming table 1 in the document and that you have a header row.
>> >>
>> >> Sub WageProtect()
>> >> '
>> >> ' WageProtect Macro
>> >> Dim oTable As Table
>> >> Set oTable = ActiveDocument.Tables(1)
>> >> ' If document is protected, Unprotect it.
>> >> If ActiveDocument.ProtectionType <> wdNoProtection Then
>> >> ActiveDocument.Unprotect Password:="fixstyles"
>> >> End If
>> >>
>> >> For i = 2 To oTable.Rows.Count
>> >> ' Insert a Field
>> >> ActiveDocument.FormFields.Add _
>> >> Range:=oTable.Cell(i, 3).Range, _
>> >> Type:=wdFieldFormTextInput
>> >> Next i
>> >>
>> >> ' ReProtect the document.
>> >> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
>> >> Password:="fixstyles", _
>> >> NoReset:=True
>> >> End Sub
>> >>
>> >> --
>> >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> >> Graham Mayor - Word MVP
>> >>
>> >> My web site www.gmayor.com
>> >> Word MVP web site http://word.mvps.org
>> >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> >>
>> >>
>> >>
>> >> JFREE223 wrote:
>> >>> Here is the logic if anybody needs it. This code is searching for
>> >>> "***"
>> >>>
>> >>> Sub WageProtect()
>> >>> '
>> >>> ' WageProtect Macro
>> >>> '
>> >>> '
>> >>>
>> >>> ' If document is protected, Unprotect it.
>> >>> If ActiveDocument.ProtectionType <> wdNoProtection Then
>> >>> ActiveDocument.Unprotect Password:="fixstyles"
>> >>> End If
>> >>>
>> >>> ' Insert a Field
>> >>> ActiveDocument.FormFields.Add Range:=Selection.Range,
>> >>> Type:=wdFieldFormTextInput
>> >>>
>> >>> Dim mySearchString As String
>> >>> Dim x As Integer
>> >>> x = 0
>> >>>
>> >>> mySearchString = "***"
>> >>>
>> >>> With Selection.Find
>> >>> .Text = mySearchString
>> >>> ' .Wrap = wdFindContinue
>> >>> Do While Selection.Find.Execute = True
>> >>> x = x + 1
>> >>> Selection.FormFields.Add Range:=Selection.Range,
>> >>> Type:=wdFieldFormTextInput
>> >>> If x > 10000 Then MsgBox "Possible Endless Loop. The macro
>> >>> has interrupted itself automatically to prevent freezing the
>> >>> computer.": End Loop
>> >>> End With
>> >>>
>> >>> ' ReProtect the document.
>> >>> If ActiveDocument.ProtectionType = wdNoProtection Then
>> >>> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
>> >>> NoReset:=True
>> >>> End If
>> >>>
>> >>> End Sub
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> "JFREE223" wrote:
>> >>>
>> >>>> I've got the code from 'Insert a Field and assign to button' from
>> >>>> Sarah_Lecturer discussion, which seems to work great. The only
>> >>>> thing I'm missing is being able to insert multiple text form fields
>> >>>> instead of one. If I could highlight the columns in the table and
>> >>>> insert all at once...great. If not, then I'd like it to identify
>> >>>> '0' and insert text form field.
>> >>>>
>> >>>> "JFREE223" wrote:
>> >>>>
>> >>>>> Oops it ran out of space. the $3,000 and $3,050 go under New
>> >>>>> Amount.
>> >>>>>
>> >>>>> "JFREE223" wrote:
>> >>>>>
>> >>>>>> Looking for a method to insert a text form field and protect a
>> >>>>>> word doc in one click. Don't know if this is even possible. I
>> >>>>>> have a document that is generated by an external system. It is
>> >>>>>> populated with several rows of dates (monthly) and corresponding
>> >>>>>> data. I need to find a method for protecting the whole document
>> >>>>>> except for a 'column' beside the pre-populated data...on
>> >>>>>> one-click if possible. The new amount column (not the header) in
>> >>>>>> the table needs to be unprotected and enterable upon clicking.
>> >>>>>> May not need a form field. If we could just protect date and
>> >>>>>> Amount upon a click, that may be an option. Thanks in advance.
>> >>>>>>
>> >>>>>> example:
>> >>>>>> Date (pre-populated) Amount (pre-populated)
>> >>>>>> New Amount 1/1/2009 $2,200.00
>> >>>>>> $3,000
>> >>>>>> 12/31/2008 $2,200.00
>> >>>>>> $3,050
>>
>>
>>