Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Powershell & Corel Draw?

408 views
Skip to first unread message

Barry S.

unread,
Nov 20, 2007, 1:41:36 AM11/20/07
to
CorelDRAW has a fairly extensive collection of VBA functions. Is
there a way to import the methods exposed for VBA in Powershell? I
recall in a DNR TV episode they used System.Reflection.Assembly to
load a DLL and then use its methods. Can I do something similar with
CorelDRAW's DLLs?

CorelDRAW has lots of DLLs, is there a base library to start from?

Thanks.


__________________
Note: To reply, replace the word 'spam' embedded in return address with 'mail'.

Marco Shaw [MVP]

unread,
Nov 20, 2007, 9:45:03 AM11/20/07
to
Barry S. wrote:
> CorelDRAW has a fairly extensive collection of VBA functions. Is
> there a way to import the methods exposed for VBA in Powershell? I
> recall in a DNR TV episode they used System.Reflection.Assembly to
> load a DLL and then use its methods. Can I do something similar with
> CorelDRAW's DLLs?
>
> CorelDRAW has lots of DLLs, is there a base library to start from?

I'm downloading a 15-day trial right now to see what it has to offer if
I can get something going quickly.

It certainly sounds possible. What is likely happening is Corel's DLLs
implement a COM interface, which PowerShell can usually interact with.

There can be some problems though.

On the other hand, the fact that System.Reflection.Assembly can be used
would seem to indicate that it is a .NET library. In the latter case,
PowerShell support would be more better.

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com

Marco Shaw [MVP]

unread,
Nov 21, 2007, 8:52:16 AM11/21/07
to
Barry S. wrote:
> CorelDRAW has a fairly extensive collection of VBA functions. Is
> there a way to import the methods exposed for VBA in Powershell? I
> recall in a DNR TV episode they used System.Reflection.Assembly to
> load a DLL and then use its methods. Can I do something similar with
> CorelDRAW's DLLs?
>
> CorelDRAW has lots of DLLs, is there a base library to start from?

I downloaded a 15-day trial.

You're right there: *lots* of DLLs!!

I went searching on DNR TV and didn't notice anything related to Corel.

I can't promise anything as it looks like I'd need to do a lot more
searching.

Oisin Grehan

unread,
Nov 21, 2007, 10:12:29 AM11/21/07
to

Hi Barry,

It might help somewhat to explain what it is you really want to do,
but anyway I'd take an educated guess that you want to create vector
drawings via powershell, and that you don't really want to extract the
"functions" alone; if this is the case, Corel Draw supports OLE
automation and built-in VBA scripting, much like the applications in
the ms office suite. The one thing that Corel Draw doesn't appear to
have though is a "primary interop assembly" which is a kind of middle-
man layer that smooths the rough edges of COM and .NET interoperation.
MSOffice provides PIAs which is why it's relatively easy to script
Word and Excel etc with Powershell. Any application that supports this
kind of scripting will usually end up exposing a rich COM api, which
you may be able to get at. So.. what's next?

I know that the file extension for corel draw files is .CDR - so the
next thing I did was look up some information on this at
http://filext.com/file-extension/CDR ; this tells me that the ProgIDs
are:

CDraw4
CorelDRAW.Graphic.8
CorelDRAW.Graphic.9
CorelDRAW.Graphic.10
CorelDRAW.Graphic.11

ProgIDs are kinda like aliases for COM objects. Next, typically you
want to drop the number suffix and just use CorelDRAW.Graphic. This is
usually aliased to the latest version. So, next step:

ps> $cdr = new-object -COM CorelDRAW.Graphic

hopefully this doesn't give an error, and if so, next thing is to try:

ps> $cdr | get-member | more

This will show all of the methods and properties on the Corel Draw
object that you can manipulate to create your vector drawing. At this
point, you can refer to your Corel VBA help to work out how to use
these methods (cos I haven't got Corel installed).

Hope this helps,

- Oisin

Barry S.

unread,
Nov 21, 2007, 8:44:22 PM11/21/07
to
On Wed, 21 Nov 2007 09:52:16 -0400, "Marco Shaw [MVP]"
<marco.shaw@_NO_SPAM_gmail.com> wrote:

>Barry S. wrote:
>> CorelDRAW has a fairly extensive collection of VBA functions. Is
>> there a way to import the methods exposed for VBA in Powershell? I
>> recall in a DNR TV episode they used System.Reflection.Assembly to
>> load a DLL and then use its methods. Can I do something similar with
>> CorelDRAW's DLLs?
>>
>> CorelDRAW has lots of DLLs, is there a base library to start from?
>
>I downloaded a 15-day trial.
>
>You're right there: *lots* of DLLs!!
>
>I went searching on DNR TV and didn't notice anything related to Corel.
>
>I can't promise anything as it looks like I'd need to do a lot more
>searching.

Marco Shaw: The DNR TV webisode was related to accessing functions in
a DLL for use in powershell. (Nothing Corel specific.)

Oisin Grehan: You nailed it. Treat as COM and refer to VBA
reference. My goal is to see if I can automate a few common tasks..
(e.g. open file, insert text filename at x,y, insert vector graphic at
x,y, export as jpg at a given resolution w/ custom compression
settings. x 2000 files)

Photopaint, the CorelDRAW eqivalent has a relatively simple scripting
language (CorelScript) that works pretty well, but CorelDRAW has
COM/VBA and I just get lost in the VBA details.

Thanks guys.

Shay Levi

unread,
Nov 22, 2007, 2:36:51 AM11/22/07
to
I used to automate such tasks with Adobe's Photoshop though never started
to do it in PowerShell.
If you're familiar with Photoshop then you can find its scripting guide inside
its installed folder under
C:\Program Files\Adobe\Adobe Photoshop [version]\Scripting Guide.

Photoshop's Scripting Guide supports COM scripting VBScript,JScript,AppleScript
and has a help file for each scripting langauge as well
as script examples.


-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com

0 new messages