🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #17602

Excel to InDesign script

#17602
From: Richard Ronnback
Date: Sat, 24 May 2003 09:48
45 lines
2398 bytes
Here's a script that imports values from Excel to InDesign. It works by using character styles that corresponds to cell references, for example, "A1, C3" etc.



 
tell application "InDesign 2.0.2" 
	set myDialog to display dialog "This script imports values from Excel cells to InDesign text marked with a corresponding character style name (example A1, C3, etc.)" buttons {"Cancel", "Continue"} default button "Continue" 
	if button returned of myDialog is "Continue" then 
		tell application "Microsoft Excel" 
			if (count of documents) is 0 then 
				Activate 
				Open (choose file with prompt "Select the Excel file you like to import values from") as string 
			end if 
			if (count of documents) is greater than 1 then 
				Activate 
				display dialog "You can only have one Excel document open when you run this script. Please close " & ((count of document) - 1) & " document(s) and run the script again" 
			end if 
			set myDocCount to count of documents 
		end tell 
	end if

	if myDocCount is 1 then 
		activate 
		set myDoc to active document 
		set myCharStyles to character styles of myDoc 
		repeat with i in myCharStyles 
			try 
				tell application "Microsoft Excel" 
					tell document 1 
						set myValue to Value of Cell (Name of i) of Sheet 1 
					end tell 
				end tell 
				if not (myValue is 0) then 
					set find preferences to nothing 
					set applied character style of find preferences to i 
					tell myDoc 
						search for "" replacing with (myValue as string) & space 
					end tell 
				end if 
			end try 
		end repeat 
		set find preferences to nothing 
		set change preferences to nothing 
	end if 
end tell 
Technical Details
Message-ID: <1de9417b.-1@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,29e51ec07bf84c0a,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-05-24 03:09:52 PST
From: "Richard Ronnback" <richard.ronnback@telia.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Excel to InDesign script
Message-ID: <1de9417b.-1@WebX.la2eafNXanI>
Date: Sat, 24 May 2003 02:48:07 -0700
Lines: 52
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit