View Single Post
 
Old 03-31-2014, 10:18 AM
Hoxton118 Hoxton118 is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Mar 2014
Posts: 21
Hoxton118 is on a distinguished road
Default Insert input box into macro to allow user to choose multiple text entries

Please could you explain how I could include code which would allow TargetList below to be populated from an input box rather than manually editing the macro. A very simple box along the lines of "Please enter text:".

It's an array so it would be good to give the user the chance to enter more than one item: so that entering "Cats, Dogs" would return Cats or Dogs.

Many thanks

Code:
'Sub CopyParas
Dim range As range
Dim i As Long
Dim TargetList
TargetList = Array("Cats", "Dogs") ' put list of terms to find here, in quotation marks, separated by commas
For i = 0 To UBound(TargetList)
Selection.Find.ClearFormatting
With Selection.Find
.Text = TargetList(i)
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do While Selection.Find.Execute
Selection.StartOf Unit:=wdParagraph
Selection.MoveEnd Unit:=wdParagraph
sBigString = sBigString + Selection.Text
Selection.MoveStart Unit:=wdParagraph
Loop
Next
Documents.Add DocumentType:=wdNewBlankDocument
Selection.InsertAfter (sBigString)
End Sub
Reply With Quote