Copy link to clipboard
Copied
Hi,
In most of tables there was an empty cells. In this cells there was white spaces and non breaking spaces are occurs. I need to delete all these spaces for all tables.
Can i have any script.
Regards,
Velu
Try this,
...for (s=0; s<app.activeDocument.stories.length; s++)
{
for (t=0; t<app.activeDocument.stories
.tables.length; t++){
app.activeDocument.stories
.tables.select(); var sel = app.activeDocument.selection[0];
if(sel instanceof Table)
{
var col = sel.columns;
for(var i=0;i<col.length;i++)
{
var cell = col.cells
for(var j=0;j<cell.length;j++)
{
Copy link to clipboard
Copied
Hi,
In UI - select a table or cell range and run Grep:
find: ^\s+$
change: <empty>
script - run changeGrep() method with chosen target, i.e.
app.activeDocument.stories.everyItem().tables.everyItem().changeGrep();
Jarek
Copy link to clipboard
Copied
Try this,
for (s=0; s<app.activeDocument.stories.length; s++)
{
for (t=0; t<app.activeDocument.stories
.tables.length; t++){
app.activeDocument.stories
.tables.select(); var sel = app.activeDocument.selection[0];
if(sel instanceof Table)
{
var col = sel.columns;
for(var i=0;i<col.length;i++)
{
var cell = col.cells
for(var j=0;j<cell.length;j++)
{
if(cell
.contents == " " || cell .contents == " ") //add your conditions here like double spaces, double non breaking space etc.. {
cell
.select(); cell
.texts[0].remove(); }
}
}
}
}
}
Vandy
Copy link to clipboard
Copied
Thaks vandy,
It working fine
Regards,
velu
Copy link to clipboard
Copied
I'm not an InDesign scripter, but IMHO your script is too complicated.
Hi VeluVK,
I'm with Jump_Over – Grep ist a good solution.
Otherwise I think you can do something like this
// RemoveSpacesFromEmptyCells.jsx
// regards pixxxelschubser
var cellTxt = app.documents.firstItem().stories.everyItem().tables.everyItem().cells.everyItem().texts.firstItem().getElements();
for ( var i = 0; i < cellTxt.length; i++ ) {
cellTxt.contents = cellTxt.contents.replace(/^\s+$/,'');
}
Have fun
![]()
Copy link to clipboard
Copied
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more