{"id":1025,"date":"2013-01-21T09:00:36","date_gmt":"2013-01-21T07:00:36","guid":{"rendered":"http:\/\/www.ozalto.com\/?p=1025"},"modified":"2016-05-18T12:37:58","modified_gmt":"2016-05-18T10:37:58","slug":"advanced-custom-text-variables","status":"publish","type":"post","link":"http:\/\/www.ozalto.com\/en\/advanced-custom-text-variables\/","title":{"rendered":"Add highly customized Text Variables to InDesign"},"content":{"rendered":"<p><strong>InDesign text variables<\/strong> are really powerful.\u00a0I recently saw a forum post where some people was asking if it was possible to add the computer name to the InDesign text variables. At first, I was about to answer him &#8220;no, you can&#8217;t&#8221;. And the fact is you normally can&#8217;t\u2026Unless you get some <strong>InDesign Scripting<\/strong> in the loop \ud83d\ude09<\/p>\n<p><!--more--><\/p>\n<p><strong>So I wrote this snippet that will add two more text variables to InDesign,<\/strong> the user name and the computer name. It&#8217;s quite open so one may tweak it for it&#8217;s own need. The only &#8220;tough&#8221; part was to get the valuable information such as the user name and the computer name. It was solved by a simple navigation inside the Folder class. Finally the user name was accessible through :<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n(Folder.myDocuments).parent.displayName;\r\n<\/pre>\n<p>And the computer name here :<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">(Folder.system).parent.displayName;<\/pre>\n<p>I have then released a first version that revealed a few hiccups. As David Buxton pointed out in his comment, what I thought was the computer name was indeed, the Hard Drive name. So I won&#8217;t get &#8220;John&#8217;s computer&#8221; as a name but maybe &#8220;Toshiba 123XDF&#8221; which was quite pointless in a production environment. <strong>Ok, I knew I have to talk a bit deeper to the system but the ExtendScript DOM can&#8217;t allow you to go that far.<\/strong> I needed to use more dedicated languages but OS specific though. In clear english, I had to use both Applescript and VisualBasic to make the script still compliant on both OS. Applescript was fine for me, not VisualBasic.<\/p>\n<p>Thanks to\u00a0Jimmy Hartington, I have been given<a title=\"VBS snippets\" href=\"http:\/\/www.robvanderwoude.com\/vbstech_network_names_computer.php\"> a link to some VBS snippets<\/a> and <a title=\"Marijan Tompa website\" href=\"http:\/\/indisnip.wordpress.com\/\">Marijan Tompa<\/a> (aka tomaxxi) offered his hand to make the vbs snippet running perfectly. In the end, I had my two OS specific snippets at hand. Fortunately, InDesign proposes a bridge to os specific code execution through the doScript method. That was it, I was then able to get the true computer name.<\/p>\n<p>Last but not least, Stephane Bosso who used the script noticed that although the text variables did appear in InDesign, they weren&#8217;t updated. Indeed, once added, the text variables kept their content through all the computers the files were open on. <strong>So I had to implement an updating mechanism in order to get this dynamic control of the system text variable.<\/strong> Now, it&#8217;s really working as expected or I hope so :).<\/p>\n<p>To get the script running effectively, you need to place it into the startup scripts folder. That way, the extra variables will always be accessible.<\/p>\n<p align=\"center\">See a demo of AddCustomVariables Script<\/p>\n<p align=\"center\"><a href=\"http:\/\/support.ozalto.com\/downloads\/demo_addCustomTextVariables.swf\"><img decoding=\"async\" class=\"aligncenter wp-image-1734 size-thumbnail\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/01\/demo_customvariables-150x150.png\" alt=\"demo_CustomVariables\" width=\"150\" height=\"150\" srcset=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/01\/demo_customvariables-150x150.png 150w, http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/01\/demo_customvariables-50x50.png 50w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a><\/p>\n<p align=\"center\"><strong>Go frenzy with\u00a0variables !<\/strong><\/p>\n<p align=\"center\"><a href=\"http:\/\/support.ozalto.com\/downloads\/addCustomVariables.zip\">Download\u00a0AddCustomVariables<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>InDesign text variables are really powerful.\u00a0I recently saw a forum post where some people was asking if it was possible to add the computer name to the InDesign text variables. At first, I was about to answer him &#8220;no, you can&#8217;t&#8221;. And the fact is you normally can&#8217;t\u2026Unless you get some InDesign Scripting in the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1023,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[43,42,5],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/1025\/"}],"collection":[{"href":"http:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/"}],"about":[{"href":"http:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/types\/post\/"}],"author":[{"embeddable":true,"href":"http:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/users\/2\/"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/comments\/?post=1025"}],"version-history":[{"count":0,"href":"http:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/1025\/revisions\/"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/media\/1023\/"}],"wp:attachment":[{"href":"http:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/media\/?parent=1025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/categories\/?post=1025"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/tags\/?post=1025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}