Results 1 to 12 of 12
  1. #1
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    automate insert picture and name (2002 SP-2)

    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.AddPictur e(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
    Guillermo

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: automate insert picture and name (2002 SP-2)

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

    <pre>Sub InsertPictures()
    ' Extract file names selected by user, and then take action on them
    With PowerPoint.Application.FileDialog(msoFileDialogFil ePicker)
    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</pre>

    Hope this helps.

  3. #3
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: automate insert picture and name (2002 SP-2)

    Its' new in 2002? I am sure I haven't seen it before.
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  4. #4
    3 Star Lounger
    Join Date
    Dec 2002
    Location
    USA
    Posts
    397
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: automate insert picture and name (2002 SP-2)

    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.

  5. #5
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: automate insert picture and name (2002 SP-2)

    I've just copied your code to my ppt visual basic and it works GREAT! <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>

    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!!!
    Guillermo

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: automate insert picture and name (2002 SP-2)

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

    .Filters.Add "Images", "*.gif; *.jpg; *.tif", 1

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: automate insert picture and name (2002 SP-2)

    Hmmm, I didn't think of that, since I pointed it to My Pictures. <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15> Anyway, HansV responded before I even made it out the door this morning.

  8. #8
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: automate insert picture and name (2002 SP-2)

    I have it in 2000
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  9. #9
    Lounger
    Join Date
    Jan 2003
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: automate insert picture and name (in 2000)

    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.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: automate insert picture and name (in 2000)


  11. #11
    3 Star Lounger
    Join Date
    Dec 2002
    Location
    USA
    Posts
    397
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select Multiple Objects tool (PowerPoint 2000+)

    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.

  12. #12
    Lounger
    Join Date
    Jan 2003
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: automate insert picture and name (in 2000)

    Wonderful! works perfectly and how obscure.

    Many, many thanks there is know way I could have found that.

Posting Permissions

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