I want to automate some steps using VBA, and I also want to be able to execute everything from the command line. In my example I'm using Corel Draw, but I think that my question is independent from Corel Draw - its more a question about namespaces.
So I wrote the following small script (called foo.vbs):
dim drawApp
Set drawApp = CreateObject( "CorelDraw.Application.14" )
drawApp.OpenDocument( "C:\foo\bar.cdr" )
Dim exportFilter
set exportFilter = drawApp.ActiveDocument.ExportBitmap("bar.png", cdrPNG, cdrAllPages, cdrRGBColorImage, 10206, 8578, 300, 300, cdrNormalAntiAliasing, False, False, True, False, cdrCompressionNone)
Then, I run it from the command line:
cscript.exe foo.vbs
I get the error that cdrPNG is not defined. Of course - I did not include any Corel Draw specific stuff into the VBScript. But how do I incluce VBA stuff that is specific for one application? (This might also enable me to write dim drawApp as CorelDRAW.Application or something like that).
I'm very new to VBA and VBScripts and I have not been able to find good tutorials or reference resources (the Microsoft site is not very helpful). Any pointers welcome.
EDIT:
I copied the ExportBitmap-part from the code that was generated when I recored a macro in Corel Draw. Studying code from recored macros seems a nice way to get to know the VBA capabilities of the software. Is there a better way?