Results 1 to 10 of 10

Thread: [RESOLVED] [Powerpoint 2007] Apply "Send to back" to shape

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    26

    Resolved [RESOLVED] [Powerpoint 2007] Apply "Send to back" to shape

    Hi,

    How do I apply 'Send to back' to a shape via macro code?

    Thanks in advance.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [Powerpoint 2007] Apply "Send to back" to shape

    vb Code:
    1. '~~> Replace "Rectangle 2" with the name of the relevant shape
    2.     ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
    3.     ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    26

    Re: [Powerpoint 2007] Apply "Send to back" to shape

    Hi Koolsid! Thanks for the code.

    I tried to combine it with

    ActiveWindow.Selection.SlideRange.Shapes.AddPicture FileName:=filnavn, LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, Left:=640, Top:=158

    like this

    ActiveWindow.Selection.SlideRange.Shapes.AddPicture FileName:=filnavn, LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, Left:=640, Top:=158, ZOrder:=msoSendToBack

    But it doesn't work.

    How can I combine the two pieces of code?

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [Powerpoint 2007] Apply "Send to back" to shape

    Is that the only shape in that window?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    26

    Re: [Powerpoint 2007] Apply "Send to back" to shape

    No, there are several other shapes.

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [Powerpoint 2007] Apply "Send to back" to shape

    Well, you need to know the name of the shape so that you can select it via code and send it to the back...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    26

    Re: [Powerpoint 2007] Apply "Send to back" to shape

    How do I then set the name of my shape when I execute this piece of code?

    ActiveWindow.Selection.SlideRange.Shapes.AddPicture FileName:=filnavn, LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, Left:=640, Top:=158

    Thanks for your help.

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [Powerpoint 2007] Apply "Send to back" to shape

    Try this... See if this helps... Remember this will only work if there is no other shape at the same co-ordinates. If there are then you might need to select different parameters...

    vb Code:
    1. Sub Shps()
    2.    
    3.     Dim Shp As Shape, ShpName As String
    4.    
    5.     '~~> Sample. Change this as per your requirement
    6.     filnavn = "C:\Documents and Settings\abhishek.shah\Desktop\koolsidz.gif"
    7.  
    8.     ActiveWindow.Selection.SlideRange.Shapes.AddPicture _
    9.     FileName:=filnavn, LinkToFile:=msoTrue, _
    10.     SaveWithDocument:=msoTrue, Left:=640, Top:=158
    11.    
    12.     '~~> This will give you the names of all the shapes in that slide
    13.     For Each Shp In ActivePresentation.Slides(1).Shapes
    14.         '~~> An alternative that I can think of is to check
    15.         '~~> the left and top of the shape and then get's it name
    16.         '~~> and then send it to the back for example
    17.         If Shp.Left = 640 And Shp.Top = 158 Then
    18.             ShpName = Shp.Name
    19.             Exit For
    20.         End If
    21.     Next
    22.    
    23.     '~~> Select Shape
    24.     ActiveWindow.Selection.SlideRange.Shapes(ShpName).Select
    25.     '~~> Send it to the back
    26.     ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack
    27. End Sub

    Hope this helps...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    26

    Re: [Powerpoint 2007] Apply "Send to back" to shape

    I ended up using your code this way:

    Code:
    'find shape name
    For Each Shp In ActivePresentation.Slides(ActiveWindow.View.Slide.SlideIndex).Shapes
    If Shp.Left = 640 And Shp.Top = 158 Then
    ShpName = Shp.Name
    Exit For
    End If
    Next
        
    'send arrow to back
    ActiveWindow.Selection.SlideRange.Shapes(ShpName).Select
    ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack
    Thank you very much for your help!

  10. #10
    Addicted Member
    Join Date
    Jan 2009
    Posts
    183

    Re: [RESOLVED] [Powerpoint 2007] Apply "Send to back" to shape

    If you're trying to move a shape that you have added via code to the back, then you don't need to loop. Just capture the shape into a variable when you add it:

    vb Code:
    1. Dim oShape As Shape
    2. Set oShape = ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:=filnavn, LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, Left:=640, Top:=158)
    3. oShape.ZOrder msoSendToBack

Posting Permissions

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



Click Here to Expand Forum to Full Width