J
jic
Greetings.
I have a Word document that has highlighted characters. I would like to "unhighlight" certain charcters based on their character codes (charCodeAt()).. I have created this JScript script,
/////////////////////////START//////////////////////////
var w = WScript;
var file = "c:\\temp\\test.doc";
var word;
var desiredColor = 7;
try
{
word = GetObject("","Word.Application");
}
catch(e)
{
word = w.CreateObject("Word.Application");
}
var doc = word.Documents.Open(file);
var myRange = doc.Range(0,0);
var chars = 1;
w.Echo("Total Characters grabbed is " + myRange.Characters.Count);
while (chars <= myRange.Characters.Count)
{
w.Echo(myRange.Characters(chars).Text.charCodeAt(0));
if (myRange.Characters(chars).Text.charCodeAt(0) == 12)
{
w.Echo("Color for code 12 is " + myRange.Characters.Parent.HighlightColorIndex);
if (myRange.Characters(chars).Parent.HighlightColorIndex == desiredColor ||
myRange.Characters(chars).Parent.HighlightColorIndex == 9999999)
{
myRange.Characters(chars).Parent.HighlightColorIndex = 0;
}
}
chars++;
}
/////////////////////////END//////////////////////////
But, somehow it is only getting one character. Any help would be greatly appreciated. Thanks.
josé
I have a Word document that has highlighted characters. I would like to "unhighlight" certain charcters based on their character codes (charCodeAt()).. I have created this JScript script,
/////////////////////////START//////////////////////////
var w = WScript;
var file = "c:\\temp\\test.doc";
var word;
var desiredColor = 7;
try
{
word = GetObject("","Word.Application");
}
catch(e)
{
word = w.CreateObject("Word.Application");
}
var doc = word.Documents.Open(file);
var myRange = doc.Range(0,0);
var chars = 1;
w.Echo("Total Characters grabbed is " + myRange.Characters.Count);
while (chars <= myRange.Characters.Count)
{
w.Echo(myRange.Characters(chars).Text.charCodeAt(0));
if (myRange.Characters(chars).Text.charCodeAt(0) == 12)
{
w.Echo("Color for code 12 is " + myRange.Characters.Parent.HighlightColorIndex);
if (myRange.Characters(chars).Parent.HighlightColorIndex == desiredColor ||
myRange.Characters(chars).Parent.HighlightColorIndex == 9999999)
{
myRange.Characters(chars).Parent.HighlightColorIndex = 0;
}
}
chars++;
}
/////////////////////////END//////////////////////////
But, somehow it is only getting one character. Any help would be greatly appreciated. Thanks.
josé