PUB2002: CMYK Color Values Different in the Object Model (285362)
The information in this article applies to:
This article was previously published under Q285362 SYMPTOMS
If you try to use Visual Basic for Applications to specify the process color values of an object, the color values are not rendered correctly on screen.
For example, the following line of code
ActiveDocument.Pages(1).Shapes(1).Fill.ForeColor.CMYK.SetCMYK 0, 0, 100, 0
creates a pale yellow with the RGB values of Red: 255, Green: 249, and Blue: 169. The CMYK values are Cyan: 0, Magenta: 0, Yellow: 39, and Black: 0.
CAUSE
This behavior can occur because Publisher uses one set of ranges in the More Colors dialog box for color settings for process CMYK colors, and a different range in Visual Basic for Applications and internally to the program for the color model.
In the More Colors dialog box, process CMYK colors range from a value of 0% to 100%.
Although the More Colors dialog box uses the range of 0 to 100 for process CMYK colors, Publisher stores process CMYK colors in memory as a range from 0 to 255. Visual Basic for Applications uses the 0 to 255 values to access the colors rather than using the 0 to 100 range.
RESOLUTIONMicrosoft provides programming examples for illustration only, without warranty either
expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes
that you are familiar with the programming language being demonstrated and the
tools used to create and debug procedures. Microsoft support professionals can
help explain the functionality of a particular procedure, but they will not
modify these examples to provide added functionality or construct procedures to
meet your specific needs. If you have limited programming experience, you may
want to contact a Microsoft Certified Partner or the Microsoft fee-based
consulting line at (800) 936-5200. For more information about Microsoft Certified
Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
The following sample code is just one way to convert CMYK values of 0 to 100 to 0 to 255. It is a function that passes the 0 to 100 values and the shape to be colored. The code does not return any value; it just changes the colol of the object on the page.
Function MakeCMYK(lC As Long, lM As Long, lY As Long, lK As Long, _
oShape As Shape)
'
' The shape is passed into the function so that
' it may be operated on directly.
'
' The function is passed the values of 0 through 100 then
' it multiplies each by 2.55 to convert it to a range of
' 0 to 255.
'
lC = lC * 2.55
lM = lM * 2.55
lY = lY * 2.55
lK = lK * 2.55
'
' Set the shape's forecolor fill to the correct CMYK
' values.
'
oShape.Fill.ForeColor.CMYK.SetCMYK lC, lM, lY, lK
End Function
Modification Type: | Major | Last Reviewed: | 11/5/2003 |
---|
Keywords: | kbprb KB285362 |
---|
|