Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PowerPoint Country Flag Pictures 1

Status
Not open for further replies.

PWD

Technical User
Jul 12, 2002
823
GB
Good afternoon, I'm automating a PowerPoint presentation and need to put the relevant country's flag in certain slides. I am more than prepared to be shot down in flames over this code, but I had to start somewhere:-

Code:
Sub NewFlags()

Country = InputBox("Enter Country", "Enter Country")

Path = "G:\folder\folder\Charts and images\Country Flags\"
''Country = "Sweden"

With ActivePresentation.Slides.Range("Slide 1")
    .Shapes.AddPicture Path & Country & ".png", False, True, 20, 405, 53, 53
End With

With ActivePresentation.Slides.Range("Slide 13")
    .Shapes.AddPicture Path & Country & ".png", False, True, 20, 405, 53, 53
End With

With ActivePresentation.Slides.Range("Slide 2")
    .Shapes.AddPicture Path & Country & ".png", False, True, 730, 0, 48, 48
End With

For S = 7 To 12 'Slides 7 to 12

With ActivePresentation.Slides.Range("Slide " & S)

    .Shapes.AddPicture Path & Country & ".png", False, True, 730, 0, 48, 48

End With

Next S
 
End Sub

Previously I had been trying to "amend the fill" of an existing object called "Country Logo" with the following code:-

Code:
    Set shp = .Shapes("Country Logo")
    
    Country = "South Africa"
    
    Select Case Country
    Case "South Africa"
    CountryFlag = "South Africa"
    Case "India"
    CountryFlag = "India"
    End Select 'Select Case country
''    MsgBox shp.Fill.Type ' = 6
    
    Call shp.Fill.UserPicture("G:\CONNECT\Useful documents\Charts and images\Country Flags\" & CountryFlag & ".png")

But that didn't work! Apparently you can't change the fill - it didn't fall over, it just didn't change the fill.

Ideally I'd like to be able to:-
1) Select the country from some sort of drop-down list.

2) Delete the object/shape "Country Logo" and then rename the newly inserted picture as that; otherwise I just get a whole stack of new pictures sitting on top of each other.

I'm also sure that there must also be a better way of getting the picture & then copying & pasting it. (Slides 1 & 13 have the flag in the same place, as do Slides 2 & 7 - 12.)

Any help will be gratefull received.

Many thanks,
D€$
 
Instead of a picture you can fill a rectangle with UserPicture method. Make the shape hidden (Visible=False) or not filled if not used.

combo
 
Well I'll be darned...... Mega thanks for that!!

My second block of code now works when applied to a rectangle!

I can apply that to the rest of slides.

BTW, is there a better way to fill each rectangle on the various sheets?

Many thanks,
D€$
 
Some things I would consider:
- use ShapeID property instead of shaperange, it is fixed for a given slide (ActivePresentation.FindBySlideID),
- use userform and a combo box to select country, this gives the user no room to make a mistake, it can also keep file names related to country,
- add two separate procedures for filling (country name as argument) and cleaning boxes,
- use PickUp and Apply to fill second and next shapes (if have the same format):
[tt]ShapeSource.PickUp
ShapeTarget1.Apply
ShapeTarget2.Apply[/tt]

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top