Using VBA to change Picture

后端 未结 10 1035
庸人自扰
庸人自扰 2020-12-10 12:41

I am trying to use VBA to automate the Change Picture function when you right click a Shape in Excel/Word/Powerpoint.

However, I am not able to find any reference, c

10条回答
  •  孤街浪徒
    2020-12-10 13:05

    I'm working in Excel and VBA. I can't overlay images because I have multiple sheets of a variable number and each sheet has the images, so the file would get huge if, say 20 sheets had all 5 images I want to animate.

    So I used a combination of these tricks listed here: 1) I inserted an RECTANGLE shape at the location and size I wanted:

    ActiveSheet.Shapes.AddShape(msoShapeRectangle, 1024#, 512#, 186#, 130#).Select
    Selection.Name = "SCOTS_WIZARD"
    With Selection.ShapeRange.Fill
      .Visible = msoTrue
      .UserPicture "G:\Users\ScotLouis\Documents\My Spreadsheets\WordFind Wizard\WordFind Wizard 1.jpg"
      .TextureTile = msoFalse
    End With
    

    2) Now to animate (change) the picture, I only need to change the Shape.Fill.UserPicture:

    ActiveSheet.Shapes("SCOTS_WIZARD").Fill.UserPicture _
        "G:\Users\ScotLouis\Documents\My Spreadsheets\WordFind Wizard\WordFind Wizard 2.jpg"
    

    So I've accomplished my goal of only having 1 picture per sheet (not 5 as in my animation) and duplicating the sheet only duplicates the active picture, so the animation continues seamlessly with the next picture.

提交回复
热议问题