F
Felipe Garcia
i have few templates that have a few variables in the
format [variable] and *variable*.
when i use the word component to find the [variable] it
works fine. but when i use the component to find the
*variable* i enter in an infinite loop.
what's wrong ?
thanks.
-- Felipe Garcia
private void ExtractManualVars(ref string
ManualVars)
{
StringBuilder sbVars;
string pattern = "*";
object objtext;
object Missing =
System.Reflection.Missing.Value;
Word.Find fnd =
_wordapp.Selection.Find;
object Format =
Word.WdFindWrap.wdFindContinue;
int docsize = 0;
int start = 0;
int end = 0;
bool ret;
sbVars = new StringBuilder();
docsize =
_worddoc.Characters.Count;
fnd.ClearFormatting();
while(end < docsize)
{
objtext = pattern;
ret = fnd.Execute(ref
objtext, ref Missing, ref Missing, ref Missing,
ref Missing, ref
Missing, ref Missing, ref Format, ref Missing,
ref Missing, ref
Missing, ref Missing, ref Missing, ref Missing, ref
Missing);
if (!ret)
return;
start =
_wordapp.Selection.Range.End;
if (start < end)
return;
objtext = pattern;
fnd.Execute(ref objtext,
ref Missing, ref Missing, ref Missing,
ref Missing, ref
Missing, ref Missing, ref Format, ref Missing,
ref Missing, ref
Missing, ref Missing, ref Missing, ref Missing, ref
Missing);
end =
_wordapp.Selection.Range.Start;
_wordapp.Selection.SetRange
(start, end);
sbVars.AppendFormat("*{0}
*,", _wordapp.Selection.Range.Text);
object objunit =
Word.WdUnits.wdWord;
object objtwo = 2;
_wordapp.Selection.Move
(ref objunit, ref objtwo);
}
}
format [variable] and *variable*.
when i use the word component to find the [variable] it
works fine. but when i use the component to find the
*variable* i enter in an infinite loop.
what's wrong ?
thanks.
-- Felipe Garcia
private void ExtractManualVars(ref string
ManualVars)
{
StringBuilder sbVars;
string pattern = "*";
object objtext;
object Missing =
System.Reflection.Missing.Value;
Word.Find fnd =
_wordapp.Selection.Find;
object Format =
Word.WdFindWrap.wdFindContinue;
int docsize = 0;
int start = 0;
int end = 0;
bool ret;
sbVars = new StringBuilder();
docsize =
_worddoc.Characters.Count;
fnd.ClearFormatting();
while(end < docsize)
{
objtext = pattern;
ret = fnd.Execute(ref
objtext, ref Missing, ref Missing, ref Missing,
ref Missing, ref
Missing, ref Missing, ref Format, ref Missing,
ref Missing, ref
Missing, ref Missing, ref Missing, ref Missing, ref
Missing);
if (!ret)
return;
start =
_wordapp.Selection.Range.End;
if (start < end)
return;
objtext = pattern;
fnd.Execute(ref objtext,
ref Missing, ref Missing, ref Missing,
ref Missing, ref
Missing, ref Missing, ref Format, ref Missing,
ref Missing, ref
Missing, ref Missing, ref Missing, ref Missing, ref
Missing);
end =
_wordapp.Selection.Range.Start;
_wordapp.Selection.SetRange
(start, end);
sbVars.AppendFormat("*{0}
*,", _wordapp.Selection.Range.Text);
object objunit =
Word.WdUnits.wdWord;
object objtwo = 2;
_wordapp.Selection.Move
(ref objunit, ref objtwo);
}
}