I can partially get around this problem by having the app and palette as
global variables so that they are obtained only once in a session. However,
if the VB app is exited and then run again (without exiting CD), the same
error occurs.
Thanks for any help...
Randy Nonay
randy...@anti-spam.net-linx.com
(just remove the obvious part...)
-------------------------------------------------------------------
Here is the code for the vb form (just has 2 buttons on the form):
Option Explicit
Option Compare Text
Private oPal As CorelDRAW.Palette
Private oApp As CorelDRAW.Application
Private Sub cmdBuildDoc_Click()
Dim oDoc As CorelDRAW.Document
Dim oPage As CorelDRAW.Page
Dim oShape As CorelDRAW.Shape
Dim oLayer As CorelDRAW.Layer
Dim oColor As CorelDRAW.Color
Dim sText As String
On Error GoTo errorhandler
oApp.Visible = True
Set oDoc = oApp.Create
Set oPage = oDoc.ActivePage
oDoc.Unit = cdrInch
oPage.SizeHeight = 1.5
oPage.SizeWidth = 1
sText = "Just some Text"
Dim nTop As Double
Dim nLeft As Double
Dim nBottom As Double
Dim nRight As Double
nTop = 1.5
nLeft = 0
nBottom = 0
nRight = 1
Set oLayer = oPage.ActiveLayer
'add background
Set oShape = oLayer.CreateRectangle(nLeft, nTop, nRight, nBottom)
oShape.Outline.Type = cdrOutline
oShape.Outline.Width = 1 / 72 '1 point
'get background color (I'll use light yellow "chalk", black outline)
For Each oColor In oPal.Colors
If oColor.Name = "chalk" Then
oShape.Fill.UniformColor = oColor
End If
If oColor.Name = "black" Then
oShape.Outline.Color = oColor
End If
Next
oShape.OrderToFront
Set oShape = oLayer.CreateArtisticText(nLeft, 0.25, sCustomer)
proc_exit:
Set oColor = Nothing
Set oShape = Nothing
Set oLayer = Nothing
Set oPage = Nothing
Set oDoc = Nothing
Exit Sub
errorhandler:
MsgBox Err.Number & " " & Err.Description
Resume proc_exit
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Form_Load()
Set oApp = CreateObject("CorelDraw.Application.9")
oApp.Visible = True
Set oPal = oApp.Palettes.Open("d:\mypal.cpl")
End Sub
> I can partially get around this problem by having the app and palette
as
> global variables so that they are obtained only once in a session.
However,
> if the VB app is exited and then run again (without exiting CD), the same
> error occurs.
This is a known CD9 problem. I don't think there's a workaround for it. I'm
not sure if this helps, but the problem has been fixed in CD10... Also, in
Draw 9, ActivePalette always returns the first open palette, not the default
one. This works fine in Draw 10 though...
--
Alex
Good to hear it is fixed in 10! We need to order one soon :-)
Thanks,
Randy Nonay
"Alex Vakulenko" <al...@vakcer.com> wrote in message news:3a673fc6@cnews...
> Hi Randy,