Consulting

Results 1 to 6 of 6

Thread: Paint Brush but a second one, independent of the first

  1. #1
    VBAX Regular
    Joined
    Dec 2018
    Posts
    24
    Location

    Paint Brush but a second one, independent of the first

    Hi, great webiste, just hoping this is possible, I have code for two tools which work separately to PPT's Format Painter (code below):

    TOOL A:
    Macro 1. Copies a shape's properties (size, colour, font, etc.) to a clipboard that's independent of the Painter or Copy tools - and stores it in memory so you can carry on working, and use later (unless you exit PPT).
    Macro 2. Converts a selected object to match the stored properties from 1.

    i.e:

    Tools A - 2 macros - copy and convert (as detailed below)
    Tools B - 2 macros - copy and convert (independent of Tool A)

    Is this possible? Thank you.

    Macro 1 - TO COPY AND STORE PROPERTIES

    Public sngW As Single
    Public sngH As Single
    Public lngRot As Long
    Public lngType As Long
    
    Sub CopyProperties()
    Dim oshp As Shape
    Set oshp = ActiveWindow.Selection.ShapeRange(1)
    oshp.PickUp
    sngW = oshp.Width
    sngH = oshp.Height
    lngRot = oshp.Rotation
    lngType = oshp.AutoShapeType
    Exit Sub
    Macro 2 - TO CONVERT AN OBJECT TO STORED PROPERTIES

    Sub ConvertProperties()
    Dim oshp As Shape
    For Each oshp In ActiveWindow.Selection.ShapeRange
    oshp.AutoShapeType = lngType
    oshp.Apply
    oshp.LockAspectRatio = False
    oshp.Width = sngW
    oshp.Height = sngH
    oshp.Rotation = lngRot
    Next oshp
    Exit Sub

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,158
    Location
    What happens/ is wrong with the code you have supplied?
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2401, Build 17231.20084

  3. #3
    VBAX Regular
    Joined
    Dec 2018
    Posts
    24
    Location
    Hi Georgi, sorry, please find the example file attached with the two macros modules.

    The slide has two objects - select the first shape, then macro 1 - then click the second shape and use macro 2 - it will convert it to look like the first shape (or any selected).

    I'm hoping to have a second one like this so two objects can be stored and reapplied, i.e. macro 1A with macro 1A (as already done) and separately a macro 1B with macro 1B, if that makes sense?

    Thank you
    Attached Files Attached Files

  4. #4
    VBAX Regular
    Joined
    Dec 2018
    Posts
    24
    Location
    I tried many ways, but failed. Here's the code (I missed off End sub above):

    Macro 1:

    Public sngW As Single
    Public sngH As Single
    Public lngRot As Long
    Public lngType As Long
    
    
    Sub CopyProperties()
    Dim oshp As Shape
    Set oshp = ActiveWindow.Selection.ShapeRange(1)
    oshp.PickUp
    sngW = oshp.Width
    sngH = oshp.Height
    lngRot = oshp.Rotation
    lngType = oshp.AutoShapeType
    Exit Sub
    End Sub
    Converting the selected macro 1 shape's properties to another object selected:

    Sub ConvertProperties()
    Dim oshp As Shape
    For Each oshp In ActiveWindow.Selection.ShapeRange
    oshp.AutoShapeType = lngType
    oshp.Apply
    oshp.LockAspectRatio = False
    oshp.Width = sngW
    oshp.Height = sngH
    oshp.Rotation = lngRot
    Next oshp
    Exit Sub
    End Sub
    Thanks in advance.

  5. #5
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,158
    Location
    Perhaps the attached will help, i have created a userform that will store the saved properties, once saved you can select another shape then select the property you want from the first listbox in the the userform and then apply that to the new shape.
    Attached Files Attached Files
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2401, Build 17231.20084

  6. #6
    VBAX Regular
    Joined
    Dec 2018
    Posts
    24
    Location
    Amazing, THANK YOU !!!! Have a great day!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •