Skip to main content
Inspiring
October 11, 2022
Answered

How to apply bold to string which is created from javascript in a document

  • October 11, 2022
  • 1 reply
  • 265 views
var imgName = "img1.tif";

myTable.columns[0].cells[0].contents = "Figure Name: " + imgName;

 

In the above code, I need to apply Bold to  "Figure Name: " alone.

Is there any way to do this?

This topic has been closed for replies.
Correct answer rob day

Hi @Karthik SG , Try this—it assumes the font has a "Bold" fontStyle

 

 

 

var imgName = "img1.tif";
var myTable = app.activeDocument.stories[0].tables[0];
myTable.columns[0].cells[0].contents = "Figure Name: " + imgName;
myTable.columns[0].cells[0].words.itemByRange(0,1).fontStyle = "Bold"

 

 

1 reply

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
October 11, 2022

Hi @Karthik SG , Try this—it assumes the font has a "Bold" fontStyle

 

 

 

var imgName = "img1.tif";
var myTable = app.activeDocument.stories[0].tables[0];
myTable.columns[0].cells[0].contents = "Figure Name: " + imgName;
myTable.columns[0].cells[0].words.itemByRange(0,1).fontStyle = "Bold"

 

 

Inspiring
October 12, 2022

Thank you @rob day , it is working!