API for MS Office 2007 for highlighting text without changing styl

A

Alexander

Hello.

Where can i find information about API for MS Office 2007 for highlighting
text without changing style/formatting, like spellchecker does it?

I need to highlight text in word, excel, powerpoint.
I found example, it works, but changes formatting.

private void FindLoop(object findText)
{
int intFound = 0;

Document document = Globals.ThisAddIn.Application.ActiveDocument;
Range rng = document.Content;

object missing = Type.Missing ;
object format = true;

rng.Find.ClearFormatting();

rng.Find.Forward = true;
rng.Find.Text = findText.ToString();
rng.Find.MatchCase = false;
rng.Find.Format = true;

rng.Find.Execute(ref findText, ref missing, ref missing, ref missing, ref
missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing);

while (rng.Find.Found)
{
intFound++;

rng.Font.Bold = 1;
rng.Font.Color = WdColor.wdColorRed;

rng.Find.Execute(
ref findText, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing);
}
}

Thanks.
 
C

Cindy M.

Hi =?Utf-8?B?QWxleGFuZGVy?=,
Where can i find information about API for MS Office 2007 for highlighting
text without changing style/formatting, like spellchecker does it?
Word has the .Range.HighlightColorIndex property which does not change the
formatting.
I need to highlight text in word, excel, powerpoint.
I found example, it works, but changes formatting.

private void FindLoop(object findText)
{
int intFound = 0;

Document document = Globals.ThisAddIn.Application.ActiveDocument;
Range rng = document.Content;

object missing = Type.Missing ;
object format = true;

rng.Find.ClearFormatting();

rng.Find.Forward = true;
rng.Find.Text = findText.ToString();
rng.Find.MatchCase = false;
rng.Find.Format = true;

rng.Find.Execute(ref findText, ref missing, ref missing, ref missing, ref
missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing);

while (rng.Find.Found)
{
intFound++;

rng.Font.Bold = 1;
rng.Font.Color = WdColor.wdColorRed;

rng.Find.Execute(
ref findText, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing);
}
}

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top