Hi everybody,
I'm using C# office (word) automation by Microsoft Office 12.0 Object Library. And I opened a "1.doc" file and I need to check if this file has a background color or not.
Note: I mean the background color applied by the following steps:
- Open MS Word 2003, and open a document.
- Go to : Format menu -> Background and choose color.
And here what I have in C#:
Object oMissing = System.Reflection.Missing.Value;
//OBJECTS OF FALSE AND TRUE
Object oTrue = true;
Object oFalse = false;
Object fileName = "c:\\1.doc";
//CREATING OBJECTS OF WORD AND DOCUMENT
Word.Application oWord = new Word.Application();
Word.Document oWordDoc = new Word.Document();
//MAKING THE APPLICATION VISIBLE
oWord.Visible = true;
//ADDING A NEW DOCUMENT TO THE APPLICATION
oWordDoc = oWord.Documents.Open(
ref fileName, ref oMissing, ref oFalse, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oTrue, ref oMissing, ref oMissing, ref oMissing);
Console.WriteLine(oWordDoc.Background.Fill.ForeColor.RGB);
Console.WriteLine(oWordDoc.Background.Fill.BackColor.RGB);
I do not know if the ForeColor or BackColor represent the color that i need, I tried to choose different background colors and executed the above code and every time I got a different integer value like (10092543, 255 for red, ....) but It does not make sense, and the BackColor is never changed and fixed at the value (16777215). Many Thanks.