Any way with a macro to get color info and output text for example
C=125 M=58 Y=14 K=0
Here is an example for uniform fill color:
Dim colorThis As Color
Set colorThis = ActiveShape.Fill.UniformColor
MsgBox "C: " & colorThis.CMYKCyan & vbCrLf & "M: " & colorThis.CMYKMagenta & vbCrLf & "Y: " & colorThis.CMYKYellow & vbCrLf & "K: " & colorThis.CMYKBlack
That looks like this in use:
Thank you so much! Any way to pass this data into the clip board? I would then paste this into a paragraph text frame.
grogo said:Any way to pass this data into the clip board?
This is some code that I have used; where it came from is noted in the comments.
You can put that in a module in your project, and then have the ClipBoard_SetData function available to use.
Private Declare PtrSafe Function GlobalUnlock Lib "kernel32" (ByVal hMem As LongPtr) As LongPtr
Private Declare PtrSafe Function GlobalLock Lib "kernel32" (ByVal hMem As LongPtr) As LongPtr
Private Declare PtrSafe Function GlobalAlloc Lib "kernel32" (ByVal wFlags As LongPtr, ByVal dwBytes As LongPtr) As LongPtr
Private Declare PtrSafe Function CloseClipboard Lib "user32" () As LongPtr
Private Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hWnd As LongPtr) As LongPtr
Private Declare PtrSafe Function EmptyClipboard Lib "user32" () As LongPtr
Private Declare PtrSafe Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, ByVal lpString2 As Any) As LongPtr
Private Declare PtrSafe Function SetClipboardData Lib "user32" (ByVal wFormat As LongPtr, ByVal hMem As LongPtr) As LongPtr
Const GHND = &H42
Const CF_TEXT = 1
Function ClipBoard_SetData(MyString As String)
'PURPOSE: API function to copy text to clipboard
Dim hGlobalMemory As LongPtr, lpGlobalMemory As LongPtr
Dim hClipMemory As LongPtr, X As LongPtr
'Allocate moveable global memory
hGlobalMemory = GlobalAlloc(GHND, Len(MyString) + 1)
'Lock the block to get a far pointer to this memory.
lpGlobalMemory = GlobalLock(hGlobalMemory)
'Copy the string to this global memory.
lpGlobalMemory = lstrcpy(lpGlobalMemory, MyString)
'Unlock the memory.
If GlobalUnlock(hGlobalMemory) <> 0 Then
MsgBox "Could not unlock memory location. Copy aborted."
'Open the Clipboard to copy data to.
If OpenClipboard(0&) = 0 Then
MsgBox "Could not open the Clipboard. Copy aborted."
'Clear the Clipboard.
X = EmptyClipboard()
'Copy the data to the Clipboard.
hClipMemory = SetClipboardData(CF_TEXT, hGlobalMemory)
If CloseClipboard() = 0 Then
MsgBox "Could not close Clipboard."
There may be something different/newer/better out there, but I haven't looked recently.
Here's something: Send information to the Clipboard.
Thanks again. Didn't think something seemingly simple would require that much code. I'll see what I can use and learn.
What about just putting the color data in a form with a select-able text box rather than a msg box?