Article View: adobe.scripting.indesign
Article #19397Sample of Using C# with InDesign Scripting
From: Chris Nicotra
Date: Tue, 17 Dec 2002 15:35
Date: Tue, 17 Dec 2002 15:35
29 lines
1768 bytes
1768 bytes
I'm new to both C# and InDesign scripting and it took me a little while to figure out how to get access the basic InDesign objects through C# so I thought this snippet of code might be useful for someone else:
InDesign.Application myApp;
InDesign.Document myDoc;
InDesign.Documents myDocs;
InDesign.Layers layers;
InDesign.Layer layer;
// Create an InDesign Application Object
Type wa = Type.GetTypeFromProgID("InDesign.Application.2.0", true);
myApp = (InDesign.Application) Activator.CreateInstance(wa);
// Get the document collection from the indesign application
myDocs = (InDesign.Documents) myApp.Documents;
// Create a new document
myDocs.Add();
// Get the active document
myDoc = (InDesign.Document) myApp.ActiveDocument;
layers = (InDesign.Layers) myDoc.Layers;
layer = (InDesign.Layer) layers.Add();
It just gets the InDesign application object, creates a document and then creates a layer.
/Chris
Technical Details
Message-ID:
<1de70a35.-1@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebXShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,f0b71c5edd9a94b5,start X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-12-17 07:38:13 PST From: "Chris Nicotra" <cgn1234@yahoo.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Sample of Using C# with InDesign Scripting Message-ID: <1de70a35.-1@WebX.la2eafNXanI> Date: Tue, 17 Dec 2002 07:35:27 -0800 Lines: 32 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit