OberonPlace.com Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old 16-01-2004, 12:25
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Quote:
Originally Posted by IanVincent
More info.. I am slowly sorting this and have it working in kind. I finally foud the text as s.text.contents. Obvious really when you think about it.
Sorry, my bad. I created my original sample for CorelDRAW 11 and then just adapted it for Draw 10 and I forgot that Shape.Text.Story is not available in Draw 10, and Shape.Text.Contents should be used instead.

Quote:
It now works providing I have the text shape selected first.
I thought that having the group of objects selected was one of your requirements. I think we should take a step back and start from the beginning. Why don't you explain exactly what you are trying to achieve and we'll start from there?
Reply With Quote
  #12  
Old 16-01-2004, 23:23
IanVincent
Guest
 
Posts: n/a
Default

No need, I almost have what I want, but there is a small bug somewhere, which I can put up with but it would be nice if that too was fixed. I had heaps of trouble because I had some of the macros duplicated in my working file and also in GlobalMacros and that seemed to trip things up. I rationalised the whole thing, so that they only appear in GlobalMacros.module2, and then call them from a button in a toolbox.

It works Ok in these situations:
When I only have a text item selected
When I have a group selected that contains an text object
When I have a text object and a curve object selected but not grouped.

But if make a mistake and select an object that is not text, or a group hat contain no text then I get a runtime error, and I would prefer that it just warned me and quit, rather than leaping out to the debugger.

I have:
Code:
Sub ExportToSWF()
    Dim fname As String
    Dim dirpath As String
    Dim fullpath As String
    Dim thistext As String
    Dim thattext As String
    Dim srBackup As ShapeRange
    Dim ss As Shape
    Dim s As Shape
    If ActiveSelection.Shapes.Count = 0 Then 'test that something is selected
        MsgBox "Nothing selected", vbCritical
        Exit Sub
    End If
    Set srBackup = ActiveSelectionRange ' Save the selection
    ActiveSelection.Duplicate 0, 0
    '... Do the export
    Set s = FindTextShape(ActiveSelection.Shapes) 'find the shape???
    If s.Type <> cdrTextShape Then
        MsgBox "no text available for filename"
        Exit Sub
    End If
    dirpath = "C:\Documents and Settings\Ian\My Documents\My Sites\Winterbrain\openeeg\op_"
    thistext = s.Text.Contents
    fname = Trim(thistext)
    fname = Replace(fname, " ", "_")
    fname = Left(fname, 20)
    fname = LCase(fname)
    fullpath = Trim(dirpath) & Trim(fname) & ".swf"   'construct fullpath
    MsgBox "fullpathname " & fullpath, vbCritical
    ActiveSelection.ConvertToCurves                   'convert to curves
    ActiveDocument.Export fullpath, cdrSWF, cdrSelection 'export to file
    ActiveSelection.Delete                            'deletes activeselection
    srBackup.CreateSelection                          'restores the activeselection
End Sub
Code:
Private Function FindTextShape(ByVal ss As Shapes) As Shape
    Dim s As Shape
    Dim sText As Shape
    
    Set sText = Nothing
    For Each s In ss
        If s.Type = cdrGroupShape Then
            Set sText = FindTextShape(s.Shapes)
            If Not sText Is Nothing Then Exit For
        ElseIf s.Type = cdrTextShape Then
            Set sText = s
            Exit For
        End If
    Next s
    Set FindTextShape = sText
End Function
Reply With Quote
  #13  
Old 17-01-2004, 00:26
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Ian,

All you need to do is check the result returned from FindTextShape function. It returns a text shape reference if found or Nothing if no text is found. So, you need to see if s is Nothing:

Code:
...
Set s = FindTextShape(ActiveSelection.Shapes)
If s Is Nothing Then
    MsgBox "Show your warning here...", vbCritical
    Exit Sub
End If
...
Reply With Quote
  #14  
Old 17-01-2004, 13:28
IanVincent
Guest
 
Posts: n/a
Default

Thanks alex..it all works fine now and is a really cool tool for me and will save me heaps of time. I really appreciate your help.
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
Deleting Shapes on the Guides Layer Rick Randall CorelDRAW/Corel DESIGNER VBA 2 28-09-2004 12:07
Transfer shapes from Draw to Paint; Using CorelScript in VB6 DWGraphics Corel Photo-Paint VBA 1 18-08-2004 21:49
Accesing CorelDraw 10 VBA Object Model without running it dolmos CorelDRAW/Corel DESIGNER VBA 5 19-12-2003 08:52
Generic code to process all shapes in a document glennwilton CorelDRAW/Corel DESIGNER VBA 0 05-09-2003 04:13
Creating macros for CorelDraw 10 in CorelDraw 11 Rick Randall CorelDRAW/Corel DESIGNER VBA 1 14-03-2003 09:00


All times are GMT -5. The time now is 07:24.


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