Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 29 of 29

Thread: Grouping of shapes in PowerPoint VBA

  1. #21
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Hello Paul, I am including something like:

    If S1.bottom falls anywhere between (S2.Top and S2.Top + 0.5). Because the shapes seems like touching but they are little away but close enough (creating an illusion). is there any effective way to check for this, can using of multiple operators cause problem?
    I used .5 as a tolerance from your PM, but you might have to adjust it to establish your own 'close enough'

    What is shape1.top + shape1.height?

    what is shape2.top?

    What is the difference?

    Attach a sample PP if you want


    Edit

    ver 3 has close shapes and a msgbox macro to show measurements

    ver 4 has different tolerances to define close (i.e 2 instead of .5)

    I don't see the behavior in your #19, so attach an example and I'll look
    Attached Files Attached Files
    Last edited by Paul_Hossler; 09-19-2019 at 07:50 AM.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  2. #22
    Quote Originally Posted by Paul_Hossler View Post
    I used .5 as a tolerance from your PM, but you might have to adjust it to establish your own 'close enough'

    What is shape1.top + shape1.height?

    what is shape2.top?

    What is the difference?

    Attach a sample PP if you want


    Edit

    ver 3 has close shapes and a msgbox macro to show measurements

    ver 4 has different tolerances to define close (i.e 2 instead of .5)

    I don't see the behavior in your #19, so attach an example and I'll look
    Attaching the sample Paul. Thank you.
    Attached Files Attached Files

  3. #23
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    I had to change my definition of 'close' to determine if 2 shapes overlapped. I assumed that each shape was +2 up, left, down and right and then checked against these slightly larger shapes

    Seem to work better in your case

    Tolerance =2 but you can change that
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #24
    Ingenious Paul!! I thought this is Impossible but you people made it easier to solve. Thanks a lot. This is new and I will learn it. I am just curious what is 'test' for in pp you attached?


    Quote Originally Posted by Paul_Hossler View Post
    I had to change my definition of 'close' to determine if 2 shapes overlapped. I assumed that each shape was +2 up, left, down and right and then checked against these slightly larger shapes

    Seem to work better in your case

    Tolerance =2 but you can change that

  5. #25
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    'Test' is a throw-away macro I wrote when I was investigating why some shapes would group when I didn't expect them to

    You can delete the entire standard module

    Option Explicit
    
    
    Sub test()
        Dim s As String
        Dim S1 As Dimensions, S2 As Dimensions
    
    
        With ActivePresentation.Slides(1)
            S1 = GetDimensions(.Shapes("myShape1"))
            S2 = GetDimensions(.Shapes("myShape2"))
            
            s = "S1 Top = " & S1.Top & vbCrLf & "s1.Height = " & S1.Height & vbCrLf & "S2 Top = " & S2.Top & vbCrLf
            s = s & "Gap = " & (S1.Top + S1.Height - S2.Top)
    
    
            MsgBox s
        End With
    
    
    End Sub
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  6. #26
    Perfect! Thank you.
    Quote Originally Posted by Paul_Hossler View Post
    'Test' is a throw-away macro I wrote when I was investigating why some shapes would group when I didn't expect them to

    You can delete the entire standard module

    Option Explicit
    
    
    Sub test()
        Dim s As String
        Dim S1 As Dimensions, S2 As Dimensions
    
    
        With ActivePresentation.Slides(1)
            S1 = GetDimensions(.Shapes("myShape1"))
            S2 = GetDimensions(.Shapes("myShape2"))
            
            s = "S1 Top = " & S1.Top & vbCrLf & "s1.Height = " & S1.Height & vbCrLf & "S2 Top = " & S2.Top & vbCrLf
            s = s & "Gap = " & (S1.Top + S1.Height - S2.Top)
    
    
            MsgBox s
        End With
    
    
    End Sub

  7. #27
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Here's a more cleaned up 'production' ready version

    This was a fun little project
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  8. #28
    Sure! Thank Paul. you are a Gem!! A light in dark tunnel.
    Quote Originally Posted by Paul_Hossler View Post
    Here's a more cleaned up 'production' ready version

    This was a fun little project

  9. #29
    Thanks John and other contributors for helping people for no reason. Thanks VBA express team!

Posting Permissions

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