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

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

Engaged ,
Oct 11, 2022 Oct 11, 2022
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?

TOPICS
How to , Scripting
169
Translate
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 , Oct 11, 2022 Oct 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"

 

 

Translate
Community Expert ,
Oct 11, 2022 Oct 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"

 

 

Translate
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
Engaged ,
Oct 11, 2022 Oct 11, 2022
LATEST

Thank you @rob day , it is working!

Translate
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