🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #16225

C# vs VB .NET, Indesign Selection property

#16225
From: john_juliuss
Date: Fri, 03 Oct 2003 07:45
35 lines
1932 bytes
I am trying to script InDesing from a C# .NET application, it mostly works fine but I have problem to get the InDesign.Selection object:s type from my C#-code. When coding "same code" in VB.NET it works fine.

This examle code assumes that text is marked in InDesign.

VB-code:

Dim idApp As InDesign.Application
Dim doc As InDesign.Document
idApp = CreateObject("InDesign.Application")
doc = idApp.ActiveDocument
Trace.Write(doc.Name)

Dim text As InDesign.Text
Dim selType As Type
selType = idApp.Selection.GetType()	' returns Syste.RunTimeType
text = idApp.Selection.Item(1)
Trace.Write(text.TextContents)	' works fine

C#-code:

Type indAppType = Type.GetTypeFromProgID("InDesign.Application", true);
InDesign.Application idApp = (InDesign.Application)Activator.CreateInstance(indAppType);
InDesign.Document doc = (InDesign.Document)idApp.ActiveDocument;

Trace.Write(doc.Name); //works fine

System.Object o = idApp.Selection;
Type tp = o.GetType(); //System.Type

InDesign.Text i = (InDesign.Text)o; //invalid cast exception?

Anyone know how to get the InDesign.Text object from InDesign.Selection property in C#-code?

thanks,
John
Technical Details
Message-ID: <2ccd9d6c.-1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!nntp.infostrada.it!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,df82d3c0c2d22515,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-10-03 01:08:20 PST
From: john_juliuss@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: C# vs VB .NET, Indesign Selection property
Message-ID: <2ccd9d6c.-1@webx.la2eafNXanI>
Date: Fri, 3 Oct 2003 00:45:11 -0700
Lines: 39
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit