473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help on .NET Word Object Library Range Find.Execute infinite Loop

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);
}

Feb 13 '07 #1
1 8746
You could try posting this to an Office Programming group. If nobody here
has an answer, maybe somebody there would.

Robin S.
----------------------------------
<wi**********@gmail.comwrote in message
news:11*********************@a75g2000cwd.googlegro ups.com...
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);
}

Feb 13 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Darryl Kerkeslager | last post by:
I hope that although this is 25% Access and 75% Word, that someone will know ... The whole problem here arises because 1) Microsoft acknowledges an 'issue' wherein TextInput type FormFields are...
4
by: Chris | last post by:
Hi, everything works apart from the last line :-(( rng.Value2.ToString() An exception is thrown : "Old format or invalid type library" It gets compiled though (so he recognizes the property...
2
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to...
2
by: Al_P via DotNetMonster.com | last post by:
I have: Win2K Office2000 Working in VB.Net (2003) My .Net project has a reference to Word 9.0 Instantiating things in a simple and straightforward manner: Dim word as Word.Application Dim...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
8
by: John Salerno | last post by:
I figured my first step is to install the win32 extension, which I did, but I can't seem to find any documentation for it. A couple of the links on Mark Hammond's site don't seem to work. ...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
1
by: mr k | last post by:
Hi, I wanted to use mail merge with forms but Text form fields are not retained during mail merge in Word, I got the code from Microsoft but it doesn't remember the text form field options such as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.