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 12-08-2010, 13:30
PAnderson PAnderson is offline
Member
 
Join Date: Nov 2003
Posts: 47
Default Paste to fit within page

I have a quilting software that allows me to copy a quilt block from the program to the Windows Clipboard as an .emf (Enhanced Metafile). The problem is, that when I paste the .emf into CorelDraw it comes in HUGE, usually over 60" width and height -- and out of proportion. There is nothing in the quilting software that allows me to adjust the size. It is what it is.

I can overcome the proportion problem by using Paste Special in CorelDRAW, but now I would like to add some code to make it fit within the current page boundaries when it pastes. How would I do that? Can I do that??

Code:
Sub PasteEQ_EMF()
    ' Pastes EQ exported Enhanced Metafile and keeps its proportions intact
    ActiveLayer.PasteSpecial "Enhanced Metafile"
    Dim Paste1 As ShapeRange
    Set Paste1 = ActiveSelectionRange
End Sub

I use this feature just about every day, so figuring this out would be a real time saver...and it would definitely keep my eyes from going buggy when I paste that .emf block!

Patti
Reply With Quote
  #2  
Old 12-08-2010, 13:49
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
I think this is what you were going for, but I may have misunderstood:

Code:
Sub PasteEQ_EMF()
    ActiveDocument.ReferencePoint = cdrBottomLeft
    If Clipboard.Empty = True Then Exit Sub
    ActiveLayer.Paste
    With ActiveShape
    .SetSize ActivePage.SizeWidth
    .SetPosition 0, 0
    End With
End Sub
-John
Reply With Quote
  #3  
Old 12-08-2010, 13:50
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
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 GetBoundingBox

I would get the Bounding Box of the Active Page, then set the Bounding Box of your pasted shape to these coordinates. Like this:
Code:
Sub PasteEQ_EMF()
    Dim Paste1 As ShapeRange
    Dim x As Double, y As Double, w As Double, h As Double
    
    ActivePage.GetBoundingBox x, y, w, h
    ActiveLayer.PasteSpecial "Enhanced Metafile"
    Set Paste1 = ActiveSelectionRange
    Paste1.SetBoundingBox x, y, w, h
End Sub
-Shelby
Reply With Quote
  #4  
Old 12-08-2010, 14:53
PAnderson PAnderson is offline
Member
 
Join Date: Nov 2003
Posts: 47
Default

Wow, you guys are fast! Tried both codes and they both almost work

John, your code worked great, except it didn't use the Paste Special "Enhanced Metafile" which I need to keep the proportions true. Once I added that it works fine for what I want.

Shelby, your code pastes the block within page, but the block is resized to fit the entire page. In other words, a square quilt block becomes 8 1/2" x 11". Maybe it could be set to fit just the width or just the height of the page, whichever is smaller?

I'll play with the code and see if I can make it do what I want. If not, I'll holler for help again.

Thanks!!
Patti
Reply With Quote
  #5  
Old 12-08-2010, 15:25
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
That's why I used setsize. You can set either and it will set the other proportionally.
Here's a simple fix for Shelby's ( I hope you don't mind Shelby):

Code:
Sub PasteEQ_EMF2()
    Dim Paste1 As ShapeRange
    Dim x As Double, y As Double, w As Double, h As Double
    
    ActivePage.GetBoundingBox x, y, w, h
    ActiveLayer.PasteSpecial "Enhanced Metafile"
    'ActiveLayer.Paste
    Set Paste1 = ActiveSelectionRange
    h = (w * Paste1.SizeHeight) / Paste1.SizeWidth '<< added
    Paste1.SetBoundingBox x, y, w, h
    
End Sub
-John
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
Copy Paste shape problem ecanseco CorelDRAW/Corel DESIGNER VBA 1 16-07-2008 23:17
Duplicating original page for multi-page layout psypha General 1 06-08-2007 14:05
best way to copy and paste a file w/ vba? xombie CorelDRAW/Corel DESIGNER VBA 4 22-11-2005 09:45
Copy/Paste doesn't seem to work. Alex FAQ 1 01-06-2005 12:25
Paste and Undo List problem Michael Cervantes Corel Photo-Paint VBA 5 11-09-2004 04:47


All times are GMT -5. The time now is 05:54.


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