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 17-11-2003, 07:26
Horst
Guest
 
Posts: n/a
Default VBA problem in PP11

Hi, Alex.

I'm trying to translate a script into VBA, but I'm having big problems
I have 2 objects and I want to add a shadow to them:
(I cut the operation in small chunks just in order to try to find the errors)

Code:
dim L as Range
dim Lrange as Range
dim Lobj as ObjectLayer
dim Lds as DropShadow

Set Lrange = ActiveDocument.Layers.Paste   'copy the objects from clipboard
set L = Lrange.Combine()        'combines the 2 objects
z=IsObject(L)                          'TRUE: just added for debugging
L.Activate             'and here I get the error "object variable not set" (freely translated into english)
set Lobj = L.ObjectLayer        
set Lds = Lobj.DropShadow       'here I want to add the shadow

Lds.angle=10      'and here I will shurely get also an error as it is Read-only: how can I set the angle of the shadow?
Hope you can help me!
Thanks
Horst[/code]
Reply With Quote
  #2  
Old 19-11-2003, 10:04
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: VBA problem in PP11

I believe you meant to declare L as "Layer", not "Range" (btw, there is no Range class, but LayerRange). However I assume you just typed your example from the head and these are just typos.

I was able to confirm your problem. Combine doesn't return a layer. However it becomes active so, you can use ActiveLayer to get to it anyway.

The worst thing is that you cannot create a dropshadow from VBA right now. Same story is pretty much for most other tools (masks, brushes, etc). The automation for those was never completed. You will have to rely on CorelScript object to get to those features.

Here is an example:

Code:
Sub Test()
    Dim lr As LayerRange
    Set lr = ActiveDocument.Layers.Paste()
    lr.Combine
    With CorelScript
        .ObjectDropShadow True, 10, 28, 22, 0, 1, 82, False, 0, 2, 1000000#, 5, 0, 0, 0, 0
        .EndObject
    End With
End Sub
Reply With Quote
  #3  
Old 19-11-2003, 12:10
Horst
Guest
 
Posts: n/a
Default

Thank you very much, Alex: are you a wizard or do you work at Corel?
I would have never thought that after 3 versions of VBA (Corel9,10 and 11) there would have still been such an error!
There must be quite a mess as I could see that:

set L=Lrange.combine()
IsObject(L): gives TRUE
VarType(L): gives 9 (i.e. an Object)
TypeName(L): gives NOTHING (i.e. NOT AN OBJECT!)

It is not easy to find out who is making the mistake: me or the computer?
But now I know, thanks to you
Horst
Reply With Quote
  #4  
Old 19-11-2003, 12:28
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Your L IS an object variable which holds a value Nothing. So VBA produces the correct result. Compare this:

Dim v As Variant

v = 0
IsObject(v) -> False
Set v = New Collection
IsObject(v) -> True
Set v = Nothing
IsObject(v) ->True
v = 5
IsObject(v) -> False

In other words, Nothing is a valid value for any object variable and it is considered as Object type. So, no error here.

The LayerRange.Combine method of PhotoPaint is another story
Reply With Quote
  #5  
Old 19-11-2003, 12:30
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

One more thing, if you want to check if an object variable actually contains a valid reference to an object, use the following syntax:

If obj Is Nothing Then
' ... variable obj has no object reference
Else
' obj has an object reference
End If

I hope this helps.
Reply With Quote
  #6  
Old 19-11-2003, 13:40
Horst
Guest
 
Posts: n/a
Default

Thanks
It wasn't explained so clearly in the Help file!
Horst
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
CD 10, VBA not returning true outline width Webster CorelDRAW/Corel DESIGNER VBA 1 24-11-2004 18:09
how to use pp11 comands in vba dnvrdave Corel Photo-Paint VBA 4 19-08-2004 11:35
VBA does not work with my CD 10 ! jobar CorelDRAW/Corel DESIGNER VBA 1 24-08-2003 13:38
VBA Editor Problem j_lyver CorelDRAW/Corel DESIGNER VBA 2 31-03-2003 06:30
Detect if VBA is installed (an answer and a question) reanan CorelDRAW/Corel DESIGNER VBA 3 04-12-2002 15:35


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


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