> Hi,
>
[quoted text clipped - 9 lines]
> If so, can it be done with a macro, or does it need something more heavy
> duty?
Yes, it can be done, and no, it is not heavy duty!
Here is my take on it:
Option Explicit
Const textFF As String = "First_Name"
Const checkFF As String = "Yes/No"
Sub FindText()
Dim rngFind As Range
Dim i As Long
i = 1
Set rngFind = ActiveDocument.Range
With rngFind.Find
.Text = textFF
Do While .Execute
AddFormField textFF, rngFind, textFF & i, "Enter your name"
i = i + 1
rngFind.Start = rngFind.End
rngFind.End = ActiveDocument.Range.End
Loop
End With
i = 1
Set rngFind = ActiveDocument.Range
With rngFind.Find
.Text = checkFF
Do While .Execute
AddFormField checkFF, rngFind, "Yes_No" & i
i = i + 1
rngFind.Start = rngFind.End
rngFind.End = ActiveDocument.Range.End
Loop
End With
End Sub
Sub AddFormField(strType As String, rngFF As Range, _
strName As String, Optional strDefault As String)
Dim frmfldReplace As FormField
Select Case strType
Case checkFF
Set frmfldReplace = rngFF.FormFields.Add(rngFF, wdFieldFormCheckBox)
With frmfldReplace
.Name = strName
End With
Case textFF
Set frmfldReplace = rngFF.FormFields.Add(rngFF, wdFieldFormTextInput)
With frmfldReplace
.Name = strName
.TextInput.Default = strDefault
.Result = .TextInput.Default
End With
End Select
End Sub
CR Geissler - 22 May 2008 20:42 GMT
Wow!
Thanks, that is great. This is exactly what I was looking for.
Cheers,
Colin
>> Hi,
>>
[quoted text clipped - 73 lines]
>
> End Sub