OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-01-2003, 10:54
schubmar
Guest
 
Posts: n/a
Default 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
Reply With Quote
  #2  
Old 17-01-2003, 13:19
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Draw Event GlobalDocument_Start

What exactly do you do in your script in Start event? Can you provide more details on your problem?
Reply With Quote
  #3  
Old 18-01-2003, 11:08
schubmar
Guest
 
Posts: n/a
Default 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
Reply With Quote
  #4  
Old 04-02-2003, 21:57
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default 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.
Reply With Quote
  #5  
Old 20-02-2003, 16:08
MrClark
Guest
 
Posts: n/a
Default 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.
Reply With Quote
  #6  
Old 21-02-2003, 08:21
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Draw Event GlobalDocument_Start

MrClark,

Good idea. Thanks for sharing...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Attributes in Corel Draw dueless CorelDRAW/Corel DESIGNER VBA 8 09-01-2008 06:56
Corel Draw 13 Anonymous General 3 06-09-2005 10:34
Draw 12 : Printing Problem Hernán General 3 20-09-2004 10:54
How can I catch the OnClose event? Elie CorelDRAW CS 2 01-04-2004 00:20
Draw hogs access to ExportBitmap created files pbarton CorelDRAW/Corel DESIGNER VBA 1 10-07-2003 15:28


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


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