OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > Corel Photo-Paint VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 28-07-2004, 17:12
DWGraphics
Guest
 
Posts: n/a
Default Transfer shapes from Draw to Paint; Using CorelScript in VB6

I am having problems transferring object from Draw11 to Paint11 using VB6. I have tried the following methods...

Method 1.

Copy selected shapes to clipboard from Draw and paste them into Paint as follows:

Code:
g_appDraw.ActiveSelection.Copy
g_appPaint.CorelScript.EditPasteObject ...
This is works correctly the first time, but subsequent uses of the ".EditPasteObject" method continue to use the original clipboard contents rather the contents I know I've placed there. I can confirm this because the macro recorder continues to say it's pasting the same temp file (e.g. 0XXX103e.TMP) located in the temp folder. If I copy new shapes to the clipboard in code and paste them manually, I get the proper results, and the temp file increments accordingly (eg 0XXX103f.TMP). If I copy new objects to the clipboard in code and paste them in code, the temp file does not increment, and the contents off the 0XXX103e.TMP file get dumped in again and again and again. ARRGGG!

Also, I've tried the following methods of clearing the clipboard first, without success

Code:
Clipboard.Clear, g_appPaint.CorelScript.EditClearClipboard)
Method 2.

Save selected shapes to a file and import them into Paint via the clipboard as follows:

Code:
g_appDraw.ActiveDocument.SaveAs sFileSpec, savOpts g_appPaint.CorelScript.EditPasteFromFile ...
I am able to get the file's contents into the Paint file (GIF format), but only at one size. Despite saving the CDR selection at various sizes, and regardless of the parameters I pass to the EditPasteFromFile method, I always get the same resulting image size. ARRGGG!


Method 3.

Save selected shapes to a file and import them into Paint via the clipboard as follows:

Code:
g_appDraw.ActiveDocument.SaveAs sFileSpec, savOpts
g_appPaint.CorelScript.FileImport sFileSpec...
Again, I am able to get the file's contents into the Paint file (GIF format), but only at one size, and regardless of the parameters I pass to the FileImport method. This is even true when my parameters exactly match those displayed in the Recorder docker when I perform the function manually. ARRGGG!

I've searched, newsgroups, the Oberon site, the Internet, and all the VBA html & pdf files that come with v11. Either v11 has some bugs in these areas or I'm missing the boat somewhere.

HELP!



Also, is there a way to reference the CorelScript object in VB6 so intellisense works? I've tried this, but it throws an error at runtime...

Code:
Dim g_appDraw as CorelDRAW.Application
Dim csc as g_appDraw.CorelScript
On the other hand, intellisense doesn't work in the IDE but the code works correctly at runtime if I use the following syntax....

Code:
Dim g_appDraw as CorelDRAW.Application
g_appDraw.CorelScript.Whatever
I get intellisense for the g_appDraw object, but nothing when I hit the period after CorelScript.

Thanks in advance for any replies

Dave
DWGraphics
Reply With Quote
  #2  
Old 18-08-2004, 20:49
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default Re: Transfer shapes from Draw to Paint; Using CorelScript in

Dave, I just used Photo-Paint's VBA commands to paste the objects and it seemed to have worked fine. Not only the first time, but also consecutive ones too...

Code:
Sub CopyFromDrawToPhotoPaint()
    Dim g_appDraw As New CorelDRAW.Application
    Dim g_appPaint As New PHOTOPAINT.Application
    
    g_appDraw.ActiveSelection.Copy
    g_appPaint.ActiveDocument.Layers.Paste
End Sub
Quote:
Originally Posted by DWGraphics
I've searched, newsgroups, the Oberon site, the Internet, and all the VBA html & pdf files that come with v11. Either v11 has some bugs in these areas or I'm missing the boat somewhere.
It is most likely there are some issues in the clipboard commands of Photo-Paint 11. Too bad you didn't specify your exact parameters to the various Paste commands you used. However as I mentioned above, the VBA's object model method seems to work. At least in my test...

Quote:
Originally Posted by DWGraphics
Also, is there a way to reference the CorelScript object in VB6 so intellisense works? I've tried this, but it throws an error at runtime...
The way you do it is like this - first define your CorelScript object as CorelScript type. Then you will be able to write your macros with intellisense:

Code:
Dim cs As PHOTOPAINT.CorelScript
Set cs = g_appPaint.CorelScript
cs.EditPasteObejct ...
Then when you are done and just before you run it, replace the definition of the variable as Object:

Code:
Dim cs As Object
The reason why it doesn't work when you define your variable as CorelScript is because CorelSCRIPT automation object doesn't support early binding. It is what's called IDispatch-only object. The CorelScript object type was added to the type library just for reference purposes. So you can use Object Browser and see what methods are available and what parameters they take. At run time, all the parameter discovery and method execution is performed dynamically. In other words, the CorelScript object is not of type "CorelScript", if that makes any sense
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
Generic code to process all shapes in a document glennwilton CorelDRAW/Corel DESIGNER VBA 0 05-09-2003 03:13


All times are GMT -5. The time now is 00:06.


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