![]() |
#1
|
|||
|
|||
![]()
During importation of data (via VBA macros) I need to create shapes in specific colors as defined by pre-generated data. These colors are generated at textual colors eg color imported as "Green", "Red", "Black" etc.
The shapes (rectangles, ellipses, text) are easily created but previous methods by settings colors has been: Select Case Color Case "Black" ActiveShape.Fill.UniformColor.RGBAssign 0, 0, 0 Case "Blue" ActiveShape.Fill.UniformColor.RGBAssign 0, 0, 255 Case "Red" ActiveShape.Fill.UniformColor.RGBAssign 255, 0, 0 | | (and so on) End Select This method was ok when 2 colors were initially introduced but has become to cumbersome with greater number of colors being used and also having to know colors prior for inclusion to above method (so macro can be updated to accommodate new color). Is there a methodology to utilise the "color" directly. I have tried several ways but with no success. I look forward to any help that may come this way. Best Regards, Denis |
#2
|
||||
|
||||
![]()
Denis,
You can look through colors in the current palette and find the color by its name. You just need to open the proper palette that contains the colors that you have and set it as a default palette. Here is a function that finds a color by its name in the current palette and returns the color found: Code:
Function GetColorByName(ByVal Name As String) As Color Dim cRet As Color Dim c As Color Set cRet = Nothing For Each c In ActivePalette.Colors If c.Name = Name Then Set cRet = c Exit For End If Next c If cRet Is Nothing Then MsgBox "Color '" & Name & "' is not found. Using black", vbExclamation Set cRet = CreateCMYKColor(0, 0, 0, 100) End If Set GetColorByName = cRet End Function Code:
Sub TestColor() ActiveShape.Fill.ApplyUniformFill GetColorByName("Ice Blue") End Sub |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
activeselection cloning | s_federici | CorelDRAW/Corel DESIGNER VBA | 2 | 05-11-2004 09:59 |
Retrieve Color Values from Selected Object | Jon Lorber | CorelDRAW/Corel DESIGNER VBA | 2 | 19-08-2004 07:24 |
Finding Color Currently Selected in RGB or CMYK Palette | AARRGGHHH | CorelDRAW/Corel DESIGNER VBA | 1 | 30-03-2004 09:03 |
Convert barcode to curves | pp21 | New product ideas | 1 | 10-03-2004 22:56 |
Selecting Obejcts with the same color - PLease help | Superfreak | CorelDRAW/Corel DESIGNER VBA | 3 | 19-03-2003 21:31 |