Scaling Macro on selected object

I recorded a macro to scale currently selected object ( it is grouped object ) by going into 100% to 300% at the top panel.

It is fine for the first object and in the macro, it is written as below:

 ActiveSelection.SetSize 5.116122, 5.117437 ( instead of 300% )

So, this scaling uses numbers instead of 300% ( percent )

so, all objects on other pages goes scaling by numbers and turned out incorrect aspect ratios. Since objects sizes are different WxH,

some objects turn out totally incorrect ratios.

Are there  ActiveSelection.SetSize routine has % percent, can I put in 300%??

And where is documentation about these functions calls???

I am using CorelDraw 2020. Thanks

  • I haven't tested this, but could you just multiply the size by 3?

        ActiveSelection.SetSize ActiveSelection.SizeWidth * 3, ActiveSelection.SizeHeight * 3

    If I'm misunderstanding the question I did have some VBA issues with scaling when importing an object, which I detailed here:https://community.coreldraw.com/talk/coreldraw-graphics-suite-2020/f/coreldraw-graphics-suite-2020-for-windows/63810/unexpected-scaling-in-vba


    Jeff

    • Jeff,  Thanks a lot. I get them working now as below as per your direction:

      Wdth = ActiveSelection.SizeWidth
      Hgth = ActiveSelection.SizeHeight
      ActiveSelection.SetSize Wdth * 3, Hgth * 3 

      I have some question on object type. I know - Query:="@type = 'text:artistic' or @type = 'text:paragraph' 

      But what type is grahpic object or a group of graphic object in here??? I can't find that in Object Brower.

      I need what type is a group??? Does this matter group has text, line, curve etc...??? Thanks 

      • This will find all the groups on the active page:

            Dim grpRange As ShapeRange
            Dim workSh As Shape
            Set grpRange = ActivePage.Shapes.FindShapes(Query:="@type = 'group'")
            MsgBox ("Found " & grpRange.count & " groups.")
            
            ' Iterate through all the groups in the grpRange
            For Each workSh In grpRange
                ' Do your work on each workSh
            Next workSh

        if you want to find the groups on multiple page then you'll need to add an outside loop to go through each page like so:

            Dim grpRange As ShapeRange
            Dim workSh As Shape
            Dim workPage As Page
            
            For Each workPage In ActiveDocument.Pages
                Set grpRange = workPage.Shapes.FindShapes(Query:="@type = 'group'")
                MsgBox ("Found " & grpRange.count & " groups on page " & workPage.Name)
            
                ' Iterate through all the groups in the grpRange
                For Each workSh In grpRange
                     ' Do your work on each workSh
                Next workSh
            Next workPage

        • Thank you so much. This is what I am looking for. Take care.

      • Hi   f you use 
        ActiveSelection.SetSize 5.116122, 5.117437 ( instead of 300% )
        it mean you SET shape size. Not scale 300%

        To scale you have to use
        ActiveSelection.Stretch koef

        where koef = 300/100 = 3

        • Oh ok Taras. I see my mistake here ( well, Corel Macro record gives me that code ).

          Thank you for your correction.

          I learn something new - so, this is also different way you could do. Thank you very much.