OberonPlace.com Forums  

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

Thread Tools Search this Thread Display Modes
Old 19-08-2009, 07:38
Posts: n/a
Default Empty Text boxes causing Runtime 91 Object Variable not set

Greetings all!

I am walking through the pages of a CorelDraw13 (on Xp Pro) document, fishing out the cdrTextShape shapes and extracting certain text.

All goes well untill VBA hits an empty text frame. "Runtime 91 Object Variable not set ... "

I am not using any With blocks.

Both stand alone and connected empty text frames cause this problem.

If a conected text frame is coverd by a stand alone text frame or other object and pushes its text to the next connected frame, it causes the problem. If a textframe is at the end of the run, and is empty, it causes the problem.

It works fine for all text frames connected or unconnected if they have some text in them. If I delete a troblesome empty standalone text frame, all is well. If I remove a redundant connected empty text frame, all is well. But I need a VBA solution.

I also noticed that wehen this occured, that VBA would move to trying to analyse ny textframe on the Master Layer, or on the desktop, before going back to the empty frame and crashing.

Can I catch the error and continue execution? Can I detect the problem and avoid it in code?

Any help appreciated please,

My code looks like this ...

 For shIdx = 1 To p.Shapes.Count
     Set thisShape = p.Shapes(shIdx)
     If thisShape.Type <> cdrTextShape Then GoTo nextShape
       ' thisShape.Text.Story.Text
         If (thisShape.Text.Frame.Range = Null) Then GoTo nextShape
        If (thisShape.Text.Frame.Range.IsEmpty = True) Then GoTo nextShape   'that is a label
         holdString = Trim((thisShape.Text.Frame.Range.Text))
       ' MsgBox "ok so far"
        howMuchText = Len(holdString)
           If howMuchText < AllTextBoxesLowersize Then GoTo nextShape

  dah dah ...

Next shIdx

Last edited by PaulANormanNZ; 19-08-2009 at 21:05.
Reply With Quote
Old 20-08-2009, 13:25
shelbym's Avatar
shelbym shelbym is offline
Senior Member
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,787
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default TextFrames

I am not 100% clear on the issue, but I played with this a little in CorelDRAW X4, and this is what I came up with. Blank or linked TextFrames do not seem to cause an issue. If you have a sample file that you get the error feel free to send it to me. Hopefully this will help.
Sub FindingText()
    Dim s As Shape, holdstring As String
    Dim howmuchtext As Integer
    For Each s In ActivePage.Shapes
        If s.Type = cdrTextShape Then
            If Not s.text.Frame.Empty Then
                holdstring = Trim(s.text.Frame.Range.text)
                howmuchtext = Len(holdstring)
                MsgBox holdstring & " " & howmuchtext
            End If
        End If
    Next s
End Sub
Reply With Quote
Old 21-08-2009, 02:15
Posts: n/a

Many thanks shelbym,

I reviewed my work and noticed that the source documents sometimes showed the problem when astistic text was involved.

So in case this helps anyone elsse this is what I did, not wanting to alter the orignal document too much.

I clone the textshape and then if it is artistic text, I convert it to paragraph text and the problem seems resolved (at the end of each loop I delete the clone).

Also I am moving through a multipage document so I also changed my code


 Set p = doc.Pages(I)
 using p.whatever
to things like

For shIdx = 1 To ActivePage.Shapes.count
And that has also helped to stabilise things.

I don't know if any of this was Corel 13 specific but it seems it may have been.

I've also put in specific error catching and asked VBA to report errors to the generated .TeX document.

If Err.Number = 91 Then  'revert to 91
   '  MsgBox "You may have an empty or obscured Text Frame on Page: " + str(I)
    buildLaTeX (vbCrLf + "There May be a problem with a TextBox: " + thisShape.Name + _
          "  ShapeNumber: " + str(shIdx) + " Corel Static Id: " + str(thisShape.ObjectData.Item("CDRstaticID").Value) + vbCrLf)
     Resume nextShape
This helps by providing the Corel Static Id of any problem text frame and I have been able to locate the exact objects in the original cdr for troubleshooting.


Last edited by PaulANormanNZ; 21-08-2009 at 02:18. Reason: spelling
Reply With Quote

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
X4 SaveAs Causing Crash burmeisn CorelDRAW/Corel DESIGNER VBA 2 15-08-2008 18:22
Object variable or with block variable not set.. m31uk3 Code Critique 2 26-12-2007 13:17
Evaluate an object name at runtime fadimas CorelDRAW/Corel DESIGNER VBA 2 14-03-2007 04:52
empty window mascotgraphics General 3 10-07-2006 05:05
object variable not found graphicdesigner CorelDRAW/Corel DESIGNER VBA 4 22-11-2004 18:13

All times are GMT -5. The time now is 14:01.

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