To get the current paragraph style settings for the second paragraph in a Text object called IntroText, use the following syntax:
ParaNum = IntroText.ParagraphIndex(0);
ParaLength = IntroText.ParagraphLength(0);
IntroText.SetSelection(ParaNum,ParaLength);
var paraInfo = IntroText.GetSelectionParagraphStyle();
Note:
The new object named paraInfo will contain all of the paragraph style information. For example, if you wanted to view the current style of justification and line spacing in the paragraph, use the following syntax:
Debug.trace(paraInfo.justification + "\n");
Debug.trace(paraInfo.linespacing);
Note:
The + "\n" part of the first line of code means to add a new line in the Debug window that appears when the Debug.trace function is run – this is purely to ensure the two bits of information appear on separate lines.
In the example below, the script is extended to show how you could change the justification for the second paragaph of the Text object named IntroText if it is currently not set to centre justification.
ParaNum = IntroText.ParagraphIndex(1);
ParaLength = IntroText.ParagraphLength(1);
IntroText.SetSelection(ParaNum,ParaLength);
var paraInfo = IntroText.GetSelectionParagraphStyle();
if (paraInfo.justification == "Left")
{
paraInfo.justification = "Centre";
IntroText.SetSelectionParagraphStyle(paraInfo);
}
see also:ParagraphIndex, ParagraphLength and SetSelectionParagraphStyle