Windows COM objects accessability
jicman
cabrera at wrc.xerox.com
Wed Sep 27 21:32:06 PDT 2006
Greetings!
This has been brought up many times before, but I don't think we've
come up with a solution, yet. Well, I haven't been around in a
while, because of lack of time and lots of work. But I am trying to
be use some COM objects and I want to use D instead of JSCript.
Here is a JSCript sample of what I want to translate:
function GetTextArt(file)
{
var appRef = w.CreateObject("Illustrator.Application.3");
docRef = appRef.Open(file);
//w.Echo(appRef.Documents.Count);
w.Echo("Found " + docRef.TextFrames.Count + " Text Frames...
Extracting them...");
var phrases = new Array();
// Prepare file...
if (docRef.TextFrames.Count == 0)
{
w.Echo("No phrase found...");
phrases.push("");
}
else
{
numberOfWords = 0
tf = new Enumerator(docRef.TextFrames);
for (; !tf.atEnd(); tf.moveNext())
{
try
{
textArt = tf.item();
}
catch (e)
{
docRef.Close(aiDoNotSaveChanges);
return (new Array());
}
try
{
textArtRange = textArt.TextRange;
}
catch (e)
{
docRef.Close(aiDoNotSaveChanges);
return (new Array());
}
phrases.push(textArt.Contents);
w.Echo(textArt.Contents);
numberOfWords += textArt.Words.Count;
}
w.Echo("There are " + numberOfWords + " words in the document.");
}
docRef.Close(aiDoNotSaveChanges);
//appRef.Quit();
return phrases;
}
So, the question is, has anyone being able to access Windows COM
objects? Any quick sample will do.
thanks,
josé
More information about the Digitalmars-d-learn
mailing list