![]() |
|
#1
|
|||
|
|||
|
Hi Folks,
I've attached the .dotm file. When the template is opened, a userform (FormMain) collects input from the user, then makes a bunch of replacements. "[n]" gets changed to the student's name, and so on. A function, "DoFindReplace," gets called for this. The "[n]" codes (tokens?) exist in my QuickParts too, so after doing all the replacements, a bunch of Custom Properties are also created/assigned. Then, later when I'm working on the student's report, and insert a QuickPart, I can run an additional module called "FixParts." This reads the Custom Properties, and calls DoFindReplace, to put the student's information into the report. This was all working nicely, but I wanted to speed up the Find and Replace function, so I tried to remove some redundancy... So now I have this in the FormMain code, and in the FixParts code: Code:
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument ' Define these here, so they're not in the func.
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
' .Text = FindText
' .Replacement.Text = ReplaceText
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = 0 'Never set this to true.
' .MatchCase = vCase
End With
Code:
Sub DoFindReplace(FindText As String, ReplaceText As String, vCase As String)
'This module gets called from the MainForm code
With Selection.Find
.Text = FindText
.Replacement.Text = ReplaceText
.MatchCase = vCase
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
So I'm guessing that I'm not using the ".Wrap = wdFindContinue" at Line 18 correctly?? Sorry about the long post -- I can explain more if needed. File is attached. General recommendations are also welcomed. And folks are welcome to use the psych report template for personal use, if anyone has a use for it. -Steve |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do you use the find and replace tool to find dates and times in Excel 2013? | Jules90 | Excel | 3 | 04-14-2020 07:40 PM |
| In Find and Replace, can Word stop after each Replace? | wardw | Word | 1 | 06-08-2017 02:47 PM |
Find what box in Find and replace limits the length of a search term
|
Hoxton118 | Word VBA | 7 | 06-10-2014 05:05 AM |
Bad view when using Find and Find & Replace - Word places found string on top line
|
paulkaye | Word | 4 | 12-06-2011 11:05 PM |
| Task type relationships not acting as expected | Rkramkowski | Project | 0 | 12-08-2005 10:40 AM |