• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Changing the color of an object

Explorer ,
Aug 22, 2014 Aug 22, 2014

Copy link to clipboard

Copied

I have tried very unsuccessfully to change the color of an object:

My simplest approach has been:

//  The current color of a pgf format is Black and I want to change it to Royal Blue

var myobject =  MyDoc.GetNamedObject(Constants.FO_PgfFmt,"Heading-3")

myobject.Color.Name = "Royal Blue";

alert(myobject.Color.Name)  // the colour is still Black

I have also tried:

var mycolorprops = myobject.Color.GetProps()

var i  = GetPropIndex(myobject.Color,Constant.Name)

mycolorprops.propVal.ival =  Constants.FV_COLOR_ROYALBLUE        

                                     or

mycolorprops.propVal.sval =  "Royal Blue"

If I can solve for Color then I will be able to work with all other commands that involve Properties.

TOPICS
Scripting

Views

799

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 22, 2014 Aug 22, 2014

Hi Bob, Here is basically how it is done:

#target framemaker

var doc = app.ActiveDoc;

// Get the required objects.

var pgfFmt = doc.GetNamedPgfFmt ("Heading1");

var color = doc.GetNamedColor ("Red");

// Apply the color object to the paragraph format.

pgfFmt.Color = color;

alert (pgfFmt.Color.Name);

One thing to be aware of: this only changes the paragraph format's color, but it does not do the equivalent of an Update All in the paragraph designer. You still have to go through and apply the u

...

Votes

Translate

Translate
Community Expert ,
Aug 22, 2014 Aug 22, 2014

Copy link to clipboard

Copied

Hi Bob, Here is basically how it is done:

#target framemaker

var doc = app.ActiveDoc;

// Get the required objects.

var pgfFmt = doc.GetNamedPgfFmt ("Heading1");

var color = doc.GetNamedColor ("Red");

// Apply the color object to the paragraph format.

pgfFmt.Color = color;

alert (pgfFmt.Color.Name);

One thing to be aware of: this only changes the paragraph format's color, but it does not do the equivalent of an Update All in the paragraph designer. You still have to go through and apply the updated paragraph format (or color) to any paragraphs tagged with this format.

Rick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 23, 2014 Aug 23, 2014

Copy link to clipboard

Copied

LATEST

Hi Rick,

Many thanks for the help.

Bob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines