Hi,
Thanks for reading this posting. I have been cracking my head on
solving the infinite loop
when i call the following section code. Any help or advise is greatly
appreciated =D
Thanks in advance.
Cheers!
Winston
//i follow the sample provided by microsoft
http://msdn2.microsoft.com/en-us/lib...rdobject_link7
Object start = 0;
Object end = oWordDoc.Charac ters.Count;
Object forward = true ;
Object wrap = Microsoft.Offic e.Interop.Word. WdFindWrap.wdFi ndStop;
Object oCollapse = WdCollapseDirec tion.wdCollapse End;
bool bFound = false;
Microsoft.Offic e.Interop.Word. Range oRng = oWordDoc.Range( ref start,
ref end);
Microsoft.Offic e.Interop.Word. Find oFnd = oRng.Find;
oFnd.ClearForma tting();
oFnd.Forward = true;
oFnd.Wrap = WdFindWrap.wdFi ndStop;
oFnd.Text = "Hello";
ExecuteFind(oFn d);
while (oFnd.Found)
{
oRng.Hyperlinks .Add(oRng, ref oURL, ref oMissing, ref oMissing,
ref oMissing,
ref oTargetFrame);
oRng.Collapse(r ef oCollapse);
ExecuteFind(oFn d);
}
private Boolean ExecuteFind(Wor d.Find find)
{
return ExecuteFind(fin d, Type.Missing, Type.Missing);
}
private Boolean ExecuteFind(
Word.Find find, Object wrapFind, Object forwardFind)
{
// Simple wrapper around Find.Execute:
Object findText = Type.Missing;
Object matchCase = Type.Missing;
Object matchWholeWord = Type.Missing;
Object matchWildcards = Type.Missing;
Object matchSoundsLike = Type.Missing;
Object matchAllWordFor ms = Type.Missing;
Object forward = forwardFind;
Object wrap = wrapFind;
Object format = Type.Missing;
Object replaceWith = Type.Missing;
Object replace = Type.Missing;
Object matchKashida = Type.Missing;
Object matchDiacritics = Type.Missing;
Object matchAlefHamza = Type.Missing;
Object matchControl = Type.Missing;
return find.Execute(re f findText, ref matchCase,
ref matchWholeWord, ref matchWildcards, ref matchSoundsLike ,
ref matchAllWordFor ms, ref forward, ref wrap, ref format,
ref replaceWith, ref replace, ref matchKashida,
ref matchDiacritics , ref matchAlefHamza, ref matchControl);
}