Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All


Sets or retrieves the foreground (text) color of the current selection.

C++ Information

Command group CGID_MSHTML (defined in mshtmhst.h)
Symbolic constant IDM_FORECOLOR
User interface None. Set nCmdExecOpt to OLECMDEXECOPT_DONTPROMPTUSER.
IOleCommandTarget::Exec parameters
pvaIn VARIANT of type VT_BSTR or VT_I4 that specifies the new color. If pvaIn is a VT_BSTR, the value can be a color name or a string representing a six-digit hexadecimal RGB color value, with or without a leading hash mark, as defined in the Color Table. If pvaIn is a VT_I4, the value will be in interpreted as a COLORREF.
pvaOut VARIANT of type VT_I4 that receives a COLORREF value. If the current selection uses more than one foreground color, pvaOut will return a VARIANT of type VT_NULL. Set pvaIn to NULL to retrieve information to pvaOut.
Header file mshtmcid.h
Applies to IHTMLDocument2::execCommand, IHTMLDocument2::queryCommandEnabled, IHTMLDocument2::queryCommandIndeterm, IHTMLDocument2::queryCommandState, IHTMLDocument2::queryCommandSupported, IHTMLDocument2::queryCommandValue, IOleCommandTarget::Exec, IOleCommandTarget::QueryStatus.


The HTML generated by this command may vary depending on the version of Windows Internet Explorer.

Minimum Availability

Internet Explorer 4.0 and later.

Community Additions

© 2015 Microsoft