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.Characters.Count;
Object forward = true ;
Object wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindSto p;
Object oCollapse = WdCollapseDirection.wdCollapseEnd;
bool bFound = false;
Microsoft.Office.Interop.Word.Range oRng = oWordDoc.Range(ref start,
ref end);
Microsoft.Office.Interop.Word.Find oFnd = oRng.Find;
oFnd.ClearFormatting();
oFnd.Forward = true;
oFnd.Wrap = WdFindWrap.wdFindStop;
oFnd.Text = "Hello";
ExecuteFind(oFnd);
while (oFnd.Found)
{
oRng.Hyperlinks.Add(oRng, ref oURL, ref oMissing, ref oMissing,
ref oMissing,
ref oTargetFrame);
oRng.Collapse(ref oCollapse);
ExecuteFind(oFnd);
}
private Boolean ExecuteFind(Word.Find find)
{
return ExecuteFind(find, 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 matchAllWordForms = 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(ref findText, ref matchCase,
ref matchWholeWord, ref matchWildcards, ref matchSoundsLike,
ref matchAllWordForms, ref forward, ref wrap, ref format,
ref replaceWith, ref replace, ref matchKashida,
ref matchDiacritics, ref matchAlefHamza, ref matchControl);
}