![]() |
#1
|
||||
|
||||
![]()
I am trying to create a macro that will...
1. Create a temporary palette from the active document... 2. cycle through the new palette... 3. for any named color, add a checkbox contol to my form. The problem I am having is step 3. What I would like to see happen is each new checkbox be named Code:
.Name = "CheckColor" & numColor I would also like to be able to create a Command button to the left of my new checkbox that will simulate the color from the palette. I assume that this needs to be done through HSV conversion, but have no idea how to begin. I tried looking through the color replacer to understand this step a little better, to no avail. Here is my code so far for the adding checkboxes... Code:
Option Explicit Private Sub UserForm_Initialize() Dim p As Page Dim CSColor As Color Dim col As New Collection Dim s As Shape Dim numColor As Integer, tp As Integer Dim CSpal As Palette Dim ClrCtrl As Control numColor = 1 tp = 18 Set CSpal = Application.Palettes.CreateFromDocument("MyPalette") For Each CSColor In CSpal.Colors If CSColor.Name <> "" Then With frmColorSeps .Controls.Add frmColorSeps!CheckBox, , Visible With ActiveControl .Name = "CheckColor" & numColor .Caption = CSColor.Name .Height = 18 .Left = 6 .Top = tp .Width = 180 End With End With tp = tp + 18 numColor = numColor + 1 End If Next CSColor End Sub
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
#2
|
|||
|
|||
![]()
here is my variant:
Code:
Option Explicit Private Sub UserForm_Initialize() Dim p As Page Dim CSColor As Color Dim col As New Collection Dim s As Shape Dim numColor As Integer, tp As Integer Dim CSpal As Palette Dim ClrCtrl As Control numColor = 1 tp = 18 Set CSpal = Application.Palettes.CreateFromDocument("MyPalette") For Each CSColor In CSpal.Colors If CSColor.Name <> "" Then With frmColorSeps1 Set ClrCtrl = Controls.Add("Forms.CheckBox.1", "", Visible) With ClrCtrl .Name = "CheckColor" & numColor .Caption = CSColor.Name .Height = 18 .Left = 6 .Top = tp .Width = 180 .Visible = True End With End With tp = tp + 18 numColor = numColor + 1 End If Next CSColor End Sub Code:
Private Sub CommandButton1_Click() With Controls("CheckColor1") MsgBox .Name & vbCrLf & .Caption & vbCrLf & .Value End With End Sub |
#3
|
|||
|
|||
![]()
Why do you refuse to use multiselect listbox? Or two listboxes - one with full list of all named colors met in document, and one with the selected ones. And buttons to add/remove from selection.
|
#4
|
||||
|
||||
![]()
zlatev, 2 words, "Stream lining".
I am trying to create text that is set in the document colors so the will print on each plate at separation time. I know there is this capability in the separations and print dialog, but the tiny size of this has caused various concerns among the "powers that be" within my company (an 11 person workforce that is family owned). The saying, "It's hard to teach an old dog new tricks." is my boss's motto. He wants to make everything idiot proof. I think, in doing so, just creates more problems, but at least I'm getting paid to do this stupid routine.
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
#5
|
||||
|
||||
![]()
In the code below, I am trying to resize the form as controls are added via userform_initialize code. At the If statement, I get an "Object variable or With block variable not set" error.
Any insight? Code:
Dim nh As Integer Private Sub UserForm_AddControl(ByVal Control As MSForms.Control) With Me If .ActiveControl.Top > 54 Then nh = nh + 18 .Height = nh End If End With End Sub
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
#6
|
|||
|
|||
![]()
Why do you want to resize the form each time a CheckBox is added? You can resize it only once, after all controls are added.
Code:
Private Sub UserForm_Initialize() ... Next CSColor frmColorSeps.Height = tp + 40 End Sub |
#7
|
||||
|
||||
![]()
My newest problem is, when I create the palette from the document, if the document contains CMYK Black, the palette shows the color name as
C0 M0 Y0 K100 I want the color to be named "Black". How can I change this via VBA?
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
#8
|
||||
|
||||
![]()
OK I fixed the part above after much hair pulling, but when it comes to Collections, I'm completely lost.
I have attached the GMS for my project. Would someone please look at it and tell me what I am doing wrong? Use the attached CDR file for testing. What is supposed to happen is this... 1. as the module starts running it creates a palette from the document then creates the controls for the form based on those colors. 2. after the form is created and presented to the user, it is up to the user to turn off color plates that aren't needed and assign a 1, 2, 3 color order in the text boxes. 3. Here comes the hard part. After creating the paragraph text on the page, the code should go back and color each line of text with the appropriate color. This is why I am trying to build a collection, so that I can reference the key for each item. If anyone can think of a different or better way to do this last part, please HELP. I'm desperate.
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
#9
|
|||
|
|||
![]()
The collection key must be string type
Code:
Collect.Add Inst, Str(numColor) here you take the idx of active palette but remove the color from CSpal palette Code:
idx = ActivePalette.GetIndexOfColor(CSColor2) CSpal.RemoveColor idx or even better: Code:
idx = CSpal.FindColor("C0 M0 Y0 K100") If idx Then CSpal.RemoveColor idx ... Last edited by Lev; 16-12-2005 at 10:31. |
#10
|
||||
|
||||
![]()
Here is what I get at the "Collect.Add Inst, Str(numColor)" line...
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
![]() |
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 |
Calendar Date Selection | ddonnahoe | CorelDRAW/Corel DESIGNER VBA | 3 | 15-01-2004 10:08 |