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 26-02-2008, 17:21
dungbtl
Guest
 
Posts: n/a
Talking Replace shape with another shape

I've tried and tried.

I cant seem to select a series of objects and replace each one selected with another kind of shape each.

The vba help book is for rectangles and ellipses, i need to replace with ready made graphic. I tried importing and replacing but i get errors because I dont know what I need to do.

Anyone?

Last edited by dungbtl; 28-02-2008 at 06:03.
Reply With Quote
  #2  
Old 26-02-2008, 20:12
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

description is too brief
Reply With Quote
  #3  
Old 27-02-2008, 11:23
dungbtl
Guest
 
Posts: n/a
Default

Sounds fair....
maybe a screenshot example.

See atatched

Thanks

for #2 - no rectangles/ellipses.

for #3 .... height or width i guess, doesnt matter.

#4 - should just end up deleted when macro finished.

now meanwhile looking at this, I dont want this, just a thought.
Maybe you can 'select' an object on the desktop/workspace screen and it could do the replacing.
Attached Images
 

Last edited by dungbtl; 27-02-2008 at 11:26.
Reply With Quote
  #4  
Old 27-02-2008, 12:34
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

forgive me showing off with virtual shapes :-) I just couldn't resist
Code:
Sub scatter()
   Dim sh As Shape, sr As ShapeRange, x#, y#, w#, h#, i&
   Dim AgentSmith As Shape, VSR As ShapeRange
   
   If ActiveDocument Is Nothing Then Exit Sub
   Set sr = ActiveSelection.Shapes.FindShapes()
   If sr.Count = 0 Then
      MsgBox "Select target objects, invoke the macro, click Agent Smith shape"
      Exit Sub
   End If
   If ActiveDocument.GetUserClick(x, y, i, -1, Snap:=false, CursorShape:=313) Then _
      Exit Sub
   
   With ActivePage.SelectShapesAtPoint(x, y, SelectUnfilled:=True)
      If .Shapes.Count = 0 Then Beep: Exit Sub
      Set AgentSmith = .Shapes(.Shapes.Count)
   End With

   Set VSR = New ShapeRange
   ActiveDocument.ReferencePoint = cdrCenter
   For Each sh In sr
      sh.GetBoundingBox x, y, w, h
      With AgentSmith.TreeNode.GetCopy
         .VirtualShape.SetBoundingBox x, y, w, h, KeepAspect:=True
         .LinkAsChildOf sh.Layer.TreeNode
         VSR.Add .VirtualShape
      End With
   Next
   
   ActiveDocument.LogCreateShapeRange VSR
   sr.delete ' evaporate originally selected shapes
End Sub

Last edited by wOxxOm; 28-02-2008 at 06:09.
Reply With Quote
  #5  
Old 28-02-2008, 05:51
dungbtl
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by wOxxOm View Post
forgive me showing off with virtual shapes :-) I just couldn't resist

Code:
Sub scatter()
  Code updated above
Im using X3.... I get error above in red

313 is a Compile Error Expected named parameter

Last edited by dungbtl; 28-02-2008 at 12:52.
Reply With Quote
  #6  
Old 28-02-2008, 06:06
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

sorry, I have edited the code to make it more understood concerning the parameters of GetUserClick in particular without testing the result :-)

if it would be interesting for you: the error is shown because I've used the named parameter in function call (Snap:=true) so all subsequent parameters should also be named, so either replace Snap:=True with True or add CursorShape:= right before 313

...:-) or just copy from my updated earlier post

I also decided to turn off Snap parameter - it causes unfilled shapes not being picked, seems like some deficiency of object model, eh

Last edited by wOxxOm; 28-02-2008 at 06:09.
Reply With Quote
  #7  
Old 28-02-2008, 12:51
dungbtl
Guest
 
Posts: n/a
Default

Incredible! This works alot more than expected.

How about this...

If the selected object is rotated.... then the new object will take the rotated degree.

Heck, you've come this far with it why not enhance it some.


Reply With Quote
  #8  
Old 28-02-2008, 12:59
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

Code:
.VirtualShape.RotationAngle = sh.RotationAngle
add this line before .VirtualShape.SetBoundingBox ....
Reply With Quote
  #9  
Old 20-05-2010, 12:56
tonic
Guest
 
Posts: n/a
Default thanks

thanks you wOxxOm, is very useful to a beginner like me
Reply With Quote
  #10  
Old 12-01-2011, 13:38
TobWen
Guest
 
Posts: n/a
Default

Thanks for this nice script, it saves a lot of time!
Would it be possible to keep the original size of virtualshape / AgentSmith?
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
Trouble wtih shape names. jahmer Macros/Add-ons 13 23-01-2008 19:05
Symbol shape is not found in a group squonk CorelDRAW/Corel DESIGNER VBA 1 14-06-2007 06:32
CorelDRAW X3 VBA Code - Shape & Color LIster JudyHNM Code Critique 2 05-04-2007 14:02
Any idea what's wrong with this shape? jemmyell CorelDRAW/Corel DESIGNER VBA 4 08-05-2006 18:15
Howto uniquely identify a shape in VBA code jemmyell CorelDRAW/Corel DESIGNER VBA 9 11-02-2005 21:05


All times are GMT -5. The time now is 08:03.


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