I'm trying to create a script which, in the process of opening a template file, asks the user for a set of CMYK values.
The idea is to then either change the value of an existing colour (called "Primary Colour") therefore changing the colour of every item to which it is applied...or add this new colour and delete 'Primary Colour' replacing it with new colour.
The problem is I can't get past creating a new colour with user input values. I can create a new colour with;
set New_Swatch to make color with properties {name:"New Primary Colour", model:process, color value:{82,72,49,46}}
however as soon as I try to replace the color value with a variable I get the error;
"Adobe InDesign CS5 got an error: Invalid parameter."
Here is a snippet of code in context;
set primaryColour to text returned of (display dialog "Enter CMYK calues of Primary Colour (separated by commas e.g. 0,0,0,0)" default answer "") as string
tell application "Adobe InDesign CS5"
activate
tell active document
set New_Swatch to make color with properties {name:"new", model:process, color value:primaryColour}
end tell
end tell
Any help gratefully received.
I currently use this:
set primaryColor to text returned of (display dialog "Enter CMYK values of Primary Colour (separated by commas e.g. 0,0,0,0)" default answer "") as string
set text item delimiters to ","
set colorvalue to {}
repeat with color from 1 to count of text items of primaryColor
copy (text item colour of primaryColor as number) to end of colorvalue
end repeat
set colorname to "TEST"
tell application "Adobe InDesign CS5"
activate
tell active document
set newcolor to make color with properties {name:colorname, space:CMYK, model:process, color value:colorvalue}
end tell
end tell
Why? Because it works. It is not pretty and it was not my first, or even 10th method to get the job done...Why this works? No idea...
It just does. You would think that:
set text item delimiters to ","
set {C,M,Y,K} to text items of primaryColor
...
set newcolor to make color with properties {name:colorname, space:CMYK, model:process, color value:{C,M,Y,K}}
Would do the trick, but it doesn't... I'm sure your attempts so far have proven just how much of a pain this particular function is.
You may also want to use the AppleScript “choose color” command, which presents a color picker, rather than presenting your user with a dialog into which they have to enter numeric color values.
This example inserts RGB colors as text into a BBEdit window, but you would use the same principle to insert CMYK colors as text into InDesign.
tell application "BBEdit"
activate
set theColorValues to choose color
set theR to round (the first item of theColorValues) / 257
set theG to round (the second item of theColorValues) / 257
set theB to round (the third item of theColorValues) / 257
set theRGBColor to "rgb(" & theR & ", " & theG & ", " & theB & ")"
set selection to theRGBColor
end tell
set primaryColor to text returned of (display dialog "Enter CMYK values of Primary Color (separated by commas e.g. 0,0,0,0)" default answer "") as string
set text item delimiters to ","
set colorvalue to {}
repeat with color from 1 to count of text items of primaryColor
copy (text item color of primaryColor as number) to end of colorvalue
end repeat
set colorname to primaryColor
tell application "Adobe InDesign CC 2017"
activate
tell active document
set newcolor to make color with properties {name:colorname, space:CMYK, model:process, color value:colorvalue}
end tell
end tell
Related
I want to read ppt and highlight certain word(background color added if background color is not possible then change the font color) in the slide. I am able to do it at sentence level i.e. if that word is contain in paragraph then it will change the font color of whole text but i want to change the color of that word only.
How about the following for highlighting?
def set_highlight(run, color):
# get run properties
rPr = run._r.get_or_add_rPr()
# Create highlight element
hl = OxmlElement("a:highlight")
# Create specify RGB Colour element with color specified
srgbClr = OxmlElement("a:srgbClr")
setattr(srgbClr, "val", color)
# Add colour specification to highlight element
hl.append(srgbClr)
# Add highlight element to run properties
rPr.append(hl)
return run
It's hacking the XML but for highlighting (text background) that's what you have to do.
I'm trying to increase the size of a checkbox in my Userform.
In the properties tab, I can change the height and the width of the object but it doesn't change the size of the square. I add a picture to explain my issue.
Thank you.
#Portland Runner's comment is a good suggestion. For example, in the click event of the label (using WingDings 2) ...
Option Explicit
Private Sub Label1_Click()
If Label1.Caption = "Q" Then
Label1.Caption = "R"
Else
Label1.Caption = "Q"
End If
End Sub
There are 2 problems with the VBA checkbox:
The size of the square
The size of the caption text
My solutions:
Create a frame in which you put the checkbox object. A frame has the property Zoom. Set that property at whatever value you want. Then change the font size of the button to match the rest of the fonts in the form. The frame doesn't have to have a title, and you can select an invisible border for it. In that way, the user doesn't see it.
For whatever reason, the checkbox's text looks smaller than the rest of the objects, even though it is the same font size. My solution for this was to remove the checkbox's text and add a standard label object to the right.
I want to place a green tick mark on a userform and thought that creating a label with the caption "a" in Marlett font would do the trick. However, Marlett isn't showing up in the object properties despite definitely being installed. I can easily place the tick mark in a cell, but not in a label. Is there a way to enable it for userforms?
There is an answer to the same problem in the c# section - How do I set button font to Marlett, but I'm not sure if it can be applied to VBA as well.
It's as simple as putting:
Label1.Font.Name = "Marlett"
Label1.Caption = "a"
(important: this code only seems to work if you set the font before setting the caption; setting the caption first seems to prevent setting the font from having an effect - thanks to #N.N.Thoughts for the info)
in the Userform_Initialize event of your userform. Replace Label1 with the name of the actual control
edit: with the addition of code to set the font size and colour:
Label1.Font.Size = "32"
Label1.ForeColor = RGB(0, 255, 0)
I'm trying to set the color of a label using one of the theme colors. For example, I want to set
lblExample.forecolor = xlThemeColorAccent2
That doesn't work and I can't find a work around
xlThemeColorAccent2 is only an index, so you need to find the list of values where the index can be used to get the full color value - and that's here:
Label1.ForeColor = ThisWorkbook.Colors(xlThemeColorAccent2)
I have a report with a lot of formulas that translate the word "TRUE" into an "X" and "FALSE" into a blank space.
I use these to put an "X" in a checkbox.
Sometimes there is text after my checkbox. To avoid slight shifts to the left and right, I print the "X" and the " " in a fixed width font. It is very tedious to manually set the font for each field.
Is there a way to specify a display font from inside the formula?
Something like this would be nice:
DisplayFontName = "Courier New"; //wishful thinking
DisplayFontSize = 8; //wishful thinking
//this is the code I'm currently using
if Uppercase({table.somefield}) = "TRUE" then "X"
else " "
No, this is not possible. The context of a formula is the property for which the formula is set only. You cannot access properties of the whole object e.g. a field. Perhaps you could think about using two images suppressed by a formula depending on the value of your field. Then you would get rid of the font problem.
From what I remember, you can set the Font using formula field where you can write
if Uppercase({table.somefield}) = "TRUE" then "Courier New"