OberonPlace.com Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 22-08-2006, 14:35
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default Overflow Error on Export

I have a form that uses the following code to paste the clipboard contents into a new document...
Code:
If clip = True Then
        Set doc1 = CreateDocument()

        ActiveLayer.Paste
        ActivePage.Shapes.All.GetSize sx, sy
        Set expflt = doc1.ExportBitmap("c:\TempView.bmp", cdrBMP, cdrCurrentPage, cdrRGBColorImage, _
            500, sy * 500 / sx, 72, 72, cdrNormalAntiAliasing, False, False, True, False, cdrCompressionNone)
        expflt.Finish
        doc1.Close
        With OrderImage
            .Picture = LoadPicture("c:\TempView.bmp")
            .PictureAlignment = fmPictureAlignmentCenter
            .PictureSizeMode = fmPictureSizeModeZoom
        End With
    End If
The probelm is, that if I select and copy text with the text tool during testing of my form, when I get to the Set expltflt... I get an overflow error.

How can I keep this error from occuring? I know, now, that the clipboard contents are not being pasted in some cases and there is nothing to export, which would explain the overflow. I tried On Error Resume Next, but it doesn't process certain code that I need run in the mean time. I'm looking for a way to alert the user that the clipboard contents are not suitable for the paste operation. Or make it so they are suitable.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #2  
Old 22-08-2006, 16:02
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

I ended up using an If...Then routine to exit sub if parameters were not met.
Code:
If clip = True Then
        Set doc1 = CreateDocument()

        ActiveLayer.Paste
        
        If ActivePage.Shapes.Count < 1 Then
            MsgBox "Clipboard contained no valid objects." & vbLf & "Please use Browse or Open Docs button.", vbCritical
            Exit Sub
        End If
        
        ActivePage.Shapes.All.GetSize sx, sy
        Set expflt = doc1.ExportBitmap("c:\TempView.bmp", cdrBMP, cdrCurrentPage, cdrRGBColorImage, _
            500, sy * 500 / sx, 72, 72, cdrNormalAntiAliasing, False, False, True, False, cdrCompressionNone)
        expflt.Finish
        doc1.Close
        With OrderImage
            .Picture = LoadPicture("c:\TempView.bmp")
            .PictureAlignment = fmPictureAlignmentCenter
            .PictureSizeMode = fmPictureSizeModeZoom
        End With
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #3  
Old 22-08-2006, 23:20
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Quote:
Originally Posted by ddonnahoe
I'm looking for a way to alert the user that the clipboard contents are not suitable for the paste operation. Or make it so they are suitable.
Have you looked at the Clipboard object in CorelDRAW? Particularly the Valid method? It is supposed to return True if there is some valid content on the clipboard that CorelDRAW can interpret... I don't think I have used this method before but could be worth a try:

Code:
Sub PasteObjects()
    If Not Clipboard.Valid Then
        MsgBox "The clipboard doesn't contain and objects CorelDRAW can understand", vbCritical
        Exit Sub
    End If
    
    ActiveLayer.Paste
End Sub
However you still need to test if the actual paste operation has succeeded just in case...
Reply With Quote
  #4  
Old 23-08-2006, 08:29
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

I use that method in the userform_initialize sub to enable/disable the from clipboard command button. I would think that if the clipboard was not valid then the button would not be enabled. If there is nothing on the clipboard it is not enabled...
Code:
btnFromClip.Enabled = False
    If Not Clipboard.Empty Then
        If Clipboard.Valid Then
            btnFromClip.Enabled = True
        End If
    End If
The clipboard contents, when it did not paste, was selected text from my code that I had copied. I would think Draw would drop this on the page as a paragraph text, but it didn't.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
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
Pdf Export Files Just Rewrite Over And Over sifterbox CorelDRAW/Corel DESIGNER VBA 10 13-12-2011 08:58
Using Macros to Export to Gif and/or EPS jfelder Macros/Add-ons 5 11-04-2008 12:33
DXF export for CAD / CAM / CNC jemmyell CorelDRAW/Corel DESIGNER VBA 5 23-02-2006 11:28
draw 11 export collection to psd xombie Code Critique 5 23-11-2005 12:02
Problem with Export (or Save as) in AI-Format LOT CorelDRAW/Corel DESIGNER VBA 3 10-02-2004 15:28


All times are GMT -5. The time now is 21:40.


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