Hello,
I have been using Corel script with Corel Draw 9 for quite some time. Now it's time to change to X3. Here is where my problem begins. There is almost no documentation regarding Corel Script (except the tutorial on this page) on the Internet, so I will try my luck here.
I have quite a large script with subs and functions, opening file dialogs and files from disk, parsing them and creating cdr file at the end. I would like to somehow use this script with X3 (the script is working with version 11).
Changing automation to .13, I get the Run-time error 1000. OLE Automation error (The selected script could not be run because there are no selected objects or the script was not dropped on an object).
Including the script in visual basic with
Code:
Sub ApplicationCorelScript()
Dim cs As Object
Set cs = CorelScript
is difficult because I have more functions and I don't know, how to "wrap" it correctly. A preview of the starting point:
Code:
' Functions declarations
declare function getGridSizeX(tablePropertiesLine as string) as integer
declare function getGridSizeY(tablePropertiesLine as string) as integer
...etc...
' Get xml file
filter$ = "XML files|*.xml|All Files|*.*"
fileFromFileBox$ = getfilebox (filter$, "Select xml file to import")
global files$(100)
if ".xml" = right(fileFromFileBox,4) then
files(1) = fileFromFileBox
else
message "not found."
stop
endif
withObject "CorelDraw.Automation.13"
global fileSettings$
global gridXpreset%
...etc...
counter% = 0
while len(files(counter+1))>0 and counter < 99
doSomeWork(files(counter+1))
counter = counter +1
wend
message "Done."
'* Functions declarations. *
sub soSomeWork (file as string)
filename$ = getOnlyFileName(file)
and so on for a few 100 lines.
Is there a simple workaround to get this working, or will I have to rewrite the whole thing to Visual Basic?
Thanks for any help in advance.