Remove empty boxes in InDesign

as prepress employee we often receive InDesignfiles with a lot of empty boxes. As this is totally useless, but sometimes gives us nightmares n our workflow, I am looking for a script what can easily remove all empty boxes. I have one for Illustrator, which I have tried to adapt toInDesign, but I couldn’t figure it out. Just as I am not an expert :frowning:

Anyone can help please?

thankx

Model: Powerbook G4
Browser: safari
Operating System: Mac OS X (10.4)

Hi KGE

Presuming your empty box’s are rectangles and they have no fill or stroke colour then this will work for you.

tell application “Adobe InDesign CS2”
activate
set myDoc to active document
tell page 1 of myDoc
delete (every rectangle whose (name of fill color is “None”) and (name of stroke color is “None”))
end tell
end tell

Budgie

Hi KGE,

The only reason that I could think of that you might want to keep a rectangle or text frame (other than it has a stroke, fill, contains text or graphic) is if it has a text wrap. As you probably already know, sometimes designers use empty boxes with text wraps applied to them in order to control text flow of another text frame, it would be bad to delete this type of object.

I took Budgie’s code and added to it.

To delete empty rectangles try this:


tell application "Adobe InDesign CS2"
	activate
	tell document 1
		set deleteCount to 0
		set everyRectangle to every rectangle
		repeat with thisRectangle in everyRectangle
			try
				set graphicProperties to properties of graphic 1 of thisRectangle
			on error
				if text wrap offset of text wrap preferences of thisRectangle is none and name of stroke color of thisRectangle is "None" and name of fill color of thisRectangle is "None" then
					delete thisRectangle
					set deleteCount to deleteCount + 1
				end if
			end try
		end repeat
	end tell
	say (deleteCount as text) using "trinoids"
	say "M T Rectangles Eliminated" using "trinoids"
end tell

To delete empty text frames try this:


tell application "Adobe InDesign CS2"
	activate
	tell document 1
		set deleteCount to 0
		set everyTextFrame to every text frame
		repeat with thisTextFrame in everyTextFrame
			if text wrap offset of text wrap preferences of thisTextFrame is none and contents of object reference of thisTextFrame is "" and name of stroke color of thisTextFrame is "None" and name of fill color of thisTextFrame is "None" then
				delete thisTextFrame
				set deleteCount to deleteCount + 1
			end if
		end repeat
	end tell
	say (deleteCount as text) using "trinoids"
	say "M T Text Frames Eliminated" using "trinoids"
end tell

CarbonQuark

:slight_smile:

Thanks guys for helping me out!! I appreciate this much.

cheers

kris