Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1097499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:26:32+00:00 2026-05-17T00:26:32+00:00

I’m using C# office ( word ) automation by Microsoft Office 12.0 Object Library

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:26:33+00:00Added an answer on May 17, 2026 at 12:26 am

    You are on the right track. The page background is indeed the foreground color of the Background object. The different values that you see correspond to the integer representation of the RGB color values.

    If you are interested in the different color components you can use the following code:

    Color color = Color.FromArgb(oWordDoc.Background.Fill.ForeColor.RGB);
    int red = color.R;
    int green = color.G;
    int blue = color.B;
    

    Update

    The color used by the Office object model seems to use a different internal format than System.Drawing.Color so the channels might get mixed up when you use the above sample code (I forgot to check the actual format of Word.ColorFormat.RGB).

    You can always retrieve the different color channels yourself using the following code:

    int wordColor = oWordDoc.Background.Fill.ForeColor.RGB;
    int channel1 = (int)((wordColor >> 0x10) & 0xffL);
    int channel2 = (int)((wordColor >> 0x8) & 0xffL);
    int channel3 = (int)(wordColor & 0xffL);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.