none
WdColor enumeration not matching for standard colors in MS Word Color Palette RRS feed

  • Question

  • In my Word 2010 document, if I change the font color of a word to any of the colors from the "Standard Colors" section of the color palette my following code does not find that color. For example, I changed the font color of a word to blue but the following code does not find that word. It seems except for Yellow color, none of the colors in the "Standard Colors" are from this "WdColor enumeration". Question: What are the WdColor values for the standards colors in color palette?

    Word.Application oApp = new Word.Application();
    Word.Document oDoc = oApp.Documents.Open(FileName: @"C:\Folder1\Test.docx");
    Word.Range oRange = oDoc.Content;
    oRange.Find.Font.Color = Word.WdColor.wdColorBlue;
    oRange.Find.Replacement.Font.Color = Word.WdColor.wdColorGreen;
    oRange.Find.Execute(Replace: Word.WdReplace.wdReplaceAll);
    ((Word._Document)oDoc).Close(SaveChanges: Word.WdSaveOptions.wdSaveChanges);
    ((Word._Application)oApp).Quit();
    Please help. Thanks..Nam




    • Edited by namwam Tuesday, April 21, 2015 3:17 AM
    Monday, April 20, 2015 3:52 AM

Answers

  • Hi namwam,

    Thanks for the clarification for this issue.

    >>. I can get the corresponding value but that value does not match as you can test my code. For instance, I chose the blue as font color (as shown in the color palette below) for a word in my Word document but my code (shown in my original post) did not find a match for that word in blue<<

    Base on my test, the name system for the color in the palette is different from the WdColor enumeration as you metioned. Here is the screenshot for your reference:

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 21, 2015 6:27 AM
    Moderator

All replies

  • Hi Nam,

    >> Question: What are the WdColor values for the standards colors in color palette?<<

    As far as I know, we can find the corresponding value based on the name of standards color. To get the name of color we can hover the mouse on the color. Here is a screenshot that getting the 'Dark Red' color for your reference:

    Then we can get the value from the WdColor enumeration based on its description:

    Member name

    Description

    wdColorDarkRed

    Dark red color.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 21, 2015 2:36 AM
    Moderator
  • Fei, it seems you misunderstood the question. I can get the corresponding value but that value does not match as you can test my code. For instance, I chose the blue as font color (as shown in the color palette below) for a word in my Word document but my code (shown in my original post) did not find a match for that word in blue. Same will be true if you search for a word with dark red font and use wdColorDarkRed in my code. I'm using VS2013 and Office 2010. Thanks..Nam

    Color Palette


    • Edited by namwam Tuesday, April 21, 2015 3:29 AM
    Tuesday, April 21, 2015 3:27 AM
  • Hi namwam,

    Thanks for the clarification for this issue.

    >>. I can get the corresponding value but that value does not match as you can test my code. For instance, I chose the blue as font color (as shown in the color palette below) for a word in my Word document but my code (shown in my original post) did not find a match for that word in blue<<

    Base on my test, the name system for the color in the palette is different from the WdColor enumeration as you metioned. Here is the screenshot for your reference:

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 21, 2015 6:27 AM
    Moderator