OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   Draw Event GlobalDocument_Start (http://forum.oberonplace.com/showthread.php?t=38)

schubmar 07-01-2003 11:54

Draw Event GlobalDocument_Start
 
Hi all,

I have written a VBA-script to generate PRN files for a mainframe system.

Now I want to automate the script so that it will start once Draw has started. When I use the event GlobalDocument_Start to call the script, the script will be excecuted and closed with no operation done.

Any ideas how to call a script after Draw has started up completely, or by external handlers like scheduler etc.

thanks in advance

Mario

Alex 17-01-2003 14:19

Re: Draw Event GlobalDocument_Start
 
What exactly do you do in your script in Start event? Can you provide more details on your problem?

schubmar 18-01-2003 12:08

re: Draw Event GlobalDocument_Start
 
Hi Alex,

I have written two script to generate PRN and PDF files from the contents of specific folders with fixed settings. I want now to automate the whole process by creating a scheduled task in windows to start Draw at a specific time, i.e. at night time to run these makros and generate the files unattended.

However when I use the named event the makros start working (debugging messages appear, but no file is converted. the makros are closed as if there where no files to convert - even if they exist.

The idea behind the makros is to look up the file name for each file in the folder and open the file, apply some settings and convert the file to a new name and location close the file and proceed to the next file until all files are done.

The problem I see with this event is, that this event is called before the Draw UI is onscreeen, and that therefore some commands simply don't work. I have checked that with a simple

"Application.OpenDocument "Fikename"

and I get a RunTimeError -2147467259(80004005) Method
"OpenDocument" for object IsDrawApplication failed.... causing Draw not to start

I am working with Draw11 (11.633) on WIN 2K SP3 (5.00.2195)

AnyOne any ideas

Alex 04-02-2003 22:57

Re: re: Draw Event GlobalDocument_Start
 
I see. You might want to go another route. If you have a stand-alone Visual Basic (not VBA) or other programming language you are versed with, you might create a separate EXE that would start a macro in CorelDRAW. The idea is to use Application.GMSManager.RunMacro method from your VB/C++/Delphi program to run the macro. This should do it fairly well and it will not rely on any event handling.

Here is how you do it in Visual Basic:
  • Create a new project
  • Add a reference to Corel - CorelDRAW 11.0 Library type library (in Project>References menu)

Then just write the following code in the code window:

Code:

Sub Main()
    Dim draw As New CorelDRAW.Application
    draw.InitializeVBA
    draw.GMSManager.RunMacro "GlobalMacros", "Module.ConvertToPDF"
    draw.Quit
End Sub

That's assuming, that your macro is in GlobalMacros VBA project, in a module file called Module. And the macro's name is ConvertToPDF.

I hope this helps.

MrClark 20-02-2003 17:08

Draw Event GlobalDocument_Start
 
I had the same problem and I came up with a solution. It is not a pretty as I would like but it lets me just launch Corel Draw with the Task scheduler and then it does its thing un attended and closes.

In Corel Draw I set the Tools>Options>Workspace>General>On CorelDRAW! Startup to: Start A New Document

Then I put my initial code in GlobalDocument_NewDocument

That way when Draw launches it completely initializes, opens a new document and runs my code. If you don't need the new document you can just add the ActiveDocument.close to the GlobalDocument_NewDocument event.

It's not as pretty as it could be but it works.

Alex 21-02-2003 09:21

Re: Draw Event GlobalDocument_Start
 
MrClark,

Good idea. Thanks for sharing...


All times are GMT -5. The time now is 08:39.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com