• automate insert picture and name (2002 SP-2)

    Home » Forums » AskWoody support » Productivity software by function » MS PowerPoint and presentation apps » automate insert picture and name (2002 SP-2)

    Author
    Topic
    #407266

    I would like to automate the following task (assign/attach to a toolbar):

    In slide mode…
    Insert / Picture / From file
    select picture, copy filename, and insert
    select picture (its selected by default after inserting), go to Format / picture / Web and enter the original name of the picture file.

    I want to do this so after I insert several pictures, I can list them by file name with the “Select Multiple Objects” tool.

    I tried the macro recorder but the only thing I get is >

    ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:=”P:My DocumentsMy Picturesworkhard.gif”, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=318, Top:=228, Width:=85, Height:=85).Select
    With ActiveWindow.Selection.ShapeRange
    .Fill.Transparency = 0#
    .AlternativeText = “workhard.gif”

    >

    Can anyone help me with the code? Thank you

    Viewing 1 reply thread
    Author
    Replies
    • #850862

      Maybe something like this? But what is the Select Multiple Objects tool?

      Sub InsertPictures()
      ' Extract file names selected by user, and then take action on them
      With PowerPoint.Application.FileDialog(msoFileDialogFilePicker)
          If .Show = -1 Then  'User didn't cancel
              Dim varFileName As Variant  'So we can use "for each" with the file names
              Dim shpPicture As Shape
              For Each varFileName In .SelectedItems
                  Set shpPicture = ActiveWindow.Selection.SlideRange. _
                                   Shapes.AddPicture(FileName:=varFileName, _
                                   LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
                                   Left:=318, Top:=228)
                  With shpPicture
                      .Fill.Transparency = 0#
                      .AlternativeText = Mid(varFileName, InStrRev(varFileName, "") + 1)
                  End With
              Next
              If Not (shpPicture Is Nothing) Then Set shpPicture = Nothing
          End If
      End With
      End Sub

      Hope this helps.

      • #851150

        I’ve just copied your code to my ppt visual basic and it works GREAT! bananas

        Only one small detail. The picture insert / open conventional window defaults to “all files” instead of only graphics files extensions. How can I modify the code so I don’t have to set it manually every time, to filter, for example, gif’s, tif’s and jpg’s only?

        THANX!!!

        • #851152

          Below the line With PowerPoint.Application.FileDialog(msoFileDialogFilePicker), insert this line:

          .Filters.Add “Images”, “*.gif; *.jpg; *.tif”, 1

        • #851153

          Below the line With PowerPoint.Application.FileDialog(msoFileDialogFilePicker), insert this line:

          .Filters.Add “Images”, “*.gif; *.jpg; *.tif”, 1

        • #851427

          Hmmm, I didn’t think of that, since I pointed it to My Pictures. laugh Anyway, HansV responded before I even made it out the door this morning.

        • #851428

          Hmmm, I didn’t think of that, since I pointed it to My Pictures. laugh Anyway, HansV responded before I even made it out the door this morning.

      • #851151

        I’ve just copied your code to my ppt visual basic and it works GREAT! bananas

        Only one small detail. The picture insert / open conventional window defaults to “all files” instead of only graphics files extensions. How can I modify the code so I don’t have to set it manually every time, to filter, for example, gif’s, tif’s and jpg’s only?

        THANX!!!

      • #1060852

        Does anyone know how to get the function in the previous post to work in PP 2000?

        I would be satified with being able to select and insert a single picture.

        Thanks in advance.

      • #850910

        But what is the Select Multiple Objects tool?

        It’s a tool you have to add to your toolbar via Tools/Customize. It basically gives you a dialog box with a list of the stuff on your slide; you tick the box beside whatever object you want to select.

        Very handy for selecting items which are below other items or otherwise difficult to select.

        Whatever text you put in the Web tab when you go to Format/Object shows up in the Select Multiple dialog, too. That’s another reason it’s handy — you can basically select objects by name if you’re disciplined about inserting descriptive text in the Format/Object/Web tab.

        • #850948

          Its’ new in 2002? I am sure I haven’t seen it before.

          • #851026

            I don’t think so, but I don’t have any earlier versions installed right now to check!

            Look under Tools/Customize/Commands. Select Multiple is in the Drawing category.

            Not many people know about it because it’s not on any toolbar by default.

          • #851027

            I don’t think so, but I don’t have any earlier versions installed right now to check!

            Look under Tools/Customize/Commands. Select Multiple is in the Drawing category.

            Not many people know about it because it’s not on any toolbar by default.

          • #855351

            I have it in 2000

          • #855352

            I have it in 2000

        • #850949

          Its’ new in 2002? I am sure I haven’t seen it before.

      • #850911

        But what is the Select Multiple Objects tool?

        It’s a tool you have to add to your toolbar via Tools/Customize. It basically gives you a dialog box with a list of the stuff on your slide; you tick the box beside whatever object you want to select.

        Very handy for selecting items which are below other items or otherwise difficult to select.

        Whatever text you put in the Web tab when you go to Format/Object shows up in the Select Multiple dialog, too. That’s another reason it’s handy — you can basically select objects by name if you’re disciplined about inserting descriptive text in the Format/Object/Web tab.

    • #850863

      Maybe something like this? But what is the Select Multiple Objects tool?

      Sub InsertPictures()
      ' Extract file names selected by user, and then take action on them
      With PowerPoint.Application.FileDialog(msoFileDialogFilePicker)
          If .Show = -1 Then  'User didn't cancel
              Dim varFileName As Variant  'So we can use "for each" with the file names
              Dim shpPicture As Shape
              For Each varFileName In .SelectedItems
                  Set shpPicture = ActiveWindow.Selection.SlideRange. _
                                   Shapes.AddPicture(FileName:=varFileName, _
                                   LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
                                   Left:=318, Top:=228)
                  With shpPicture
                      .Fill.Transparency = 0#
                      .AlternativeText = Mid(varFileName, InStrRev(varFileName, "") + 1)
                  End With
              Next
              If Not (shpPicture Is Nothing) Then Set shpPicture = Nothing
          End If
      End With
      End Sub

      Hope this helps.

    Viewing 1 reply thread
    Reply To: automate insert picture and name (2002 SP-2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: