<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Publishing with Silicon &#187; Access</title>
	<atom:link href="http://blog.siliconpublishing.com/tag/access/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.siliconpublishing.com</link>
	<description>Max Dunn&#039;s electronic publishing blog: reconciling information and rendition technologies</description>
	<lastBuildDate>Mon, 06 Dec 2010 08:03:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>InDesign Scripting with VBA Example</title>
		<link>http://blog.siliconpublishing.com/2009/11/indesign-scripting-with-vba-example/</link>
		<comments>http://blog.siliconpublishing.com/2009/11/indesign-scripting-with-vba-example/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 07:57:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[InDesign]]></category>
		<category><![CDATA[Access]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://www.publishingsilicon.com/?p=37</guid>
		<description><![CDATA[Discussion of VBA vs. JavaScript scripting of InDesign]]></description>
			<content:encoded><![CDATA[<p>I was pleased to see that <a href="http://www.siliconpublishing.com/InDesign/CatalogExample.htm">my old example</a> still runs in CS4. Using VBA was very cool, it just suffered from dependency on Windows. But functionally we did many applications back in the early days of InDesign that worked just great with VBA. I think it was VB and AppleScript prior to JS and the cross-platform scripting? Let me go look that up.</p>
<p>In any case while JS scripting seems far more useful now, or &#8220;ExtendScript&#8221; as they call it, we still suffer from the sandbox and the inability to shell out to data sources and do work with them then get right back to automating InDesign. Using Java one can do such things with InDesign Server, but the Server-only nature of the Java makes debugging difficult. Its strongly-typed nature is a big headache, as with C# or any strongly typed language: you spend more time figuring out what type object you&#8217;re working with than you do manipulating the object.</p>
<p>I want to translate the VBA example to JavaScript with some database such as MySQL. In general the power of InDesign to do data-generated publishing is awesome.</p>
<p>Yes, JavaScript is better. VB is actually buggy&#8230; How come this JS works:<br />
<code><br />
var myDocument = app.documents.item(0);<br />
var myRectangle = myDocument.rectangles.item(0);<br />
myHyperlinkURL = myDocument.hyperlinkURLDestinations.add("http://www.publishingsilicon.com");<br />
myHyperlinkSource = myDocument.hyperlinkPageItemSources.add(myRectangle);<br />
myHyperlink=myDocument.hyperlinks.add(myHyperlinkSource,myHyperlinkURL);<br />
myHyperlink.visible=false;<br />
</code><br />
and this equivalent in VB doesn&#8217;t:<br />
<code><br />
Dim oInDesign As InDesign.Application<br />
Dim oDocument As InDesign.Document<br />
Dim oPage As InDesign.Page<br />
Dim oImageRect As InDesign.Rectangle<br />
Dim oHyperlinkURL As InDesign.HyperlinkURLDestination<br />
Dim oHyperlinkSource As InDesign.HyperlinkPageItemSource<br />
Dim oHyperlink As InDesign.Hyperlink<br />
Set oInDesign = CreateObject("InDesign.Application.CS4")<br />
Set oDocument = oInDesign.ActiveDocument<br />
Set oImageRect = oDocument.Rectangles.Item(1)<br />
Set oHyperlinkURL = oDocument.HyperlinkURLDestinations.Add("http://www.publishingsilicon.com")<br />
Set oHyperlinkSource = oDocument.HyperlinkPageItemSources.Add(oImageRect)<br />
Set oHyperlink = oDocument.Hyperlinks.Add(oHyperlinkSource, oHyperlinkURL)<br />
oHyperlink.Visible = False<br />
</code><br />
?</p>
<p>The VBA version bombs on the line with oDocument.HyperlinkPageItemSources.Add&#8230; and this sort of thing was <a href="http://forums.adobe.com/message/1111958#1111958">posted to the forums</a> over a year ago. I guess yet another reason the cross-platform JavaScript form of InDesign scripting is better is that it enjoys support. Can hardly blame Adobe for limiting support, especially as they cut 9% of their workforce when holiday season comes along. You can&#8217;t fight every battle.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.siliconpublishing.com/2009/11/indesign-scripting-with-vba-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

