Martijn6134
11-09-2016, 08:00 AM
Hey John,
I'll post the code I have currently at the end of this message.
In general I want to find the easiest way of doing it. In total were talking of 546 items that I would have in the list which I should be able to select manually. If I want to do it the way I want to, I would need to make 546 macros and then one main macro which creates the eventual slideshow. This is gonna take me a while to create so the least amount of changes I have to make to the script each time I copy paste, the better it is :D There probably is a lot I can do more efficient in the code I have but like I said, I'm a complete noob at programming and the code I have right now is something that I made a while ago and which I am now using to create a different macro.
If you look at the code it says:
strEquip1 = "2S1"
strEquip2 = "SU27"
These I want to be set to the corresponding items which I would click on in the powerpoint. This will go op to strEquip546 eventually.
In the bottom there's a rough visualization of which I want to create. What it boils down to is that I have a powerpoint slideshow with multiple pages like this I can navigate through. I want to be able to select certain items and then click on the create button which will run the script I currently have with all those items selected in there as a strEquip.
Sub AutoReco()
Dim strTemp As String
Dim strPath As String
Dim strFileSpec As String
Dim oSld As Slide
Dim oPic As Shape
Dim oPic2 As Shape
Dim oTxt As Shape
Dim oTxt2 As Shape
Dim oTxt3 As Shape
Dim oBoxTop As Shape
Dim oBoxBottom As Shape
Dim strEquip(1 To 2) As String
strEquip1 = "2S1"
strEquip2 = "SU27"
strPath = ActivePresentation.Path & "\MEDIA\"
strFileSpec = "*.*"
strTemp = Dir(strPath & strEquip1 & "\" & strFileSpec)
Do While strTemp <> ""
Set oSld = ActivePresentation.Slides.Add(ActivePresentation.Slides.Count + 1, ppLayoutBlank)
Set oPic = oSld.Shapes.AddPicture(FileName:=strPath & strEquip1 & "\" & strTemp, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=0, _
Top:=0, _
Width:=-1, _
Height:=-1)
Set oBoxTop = oSld.Shapes.AddShape(msoShapeRectangle, _
Left:=0, Top:=0, Width:=720, Height:=60)
Set oBoxBottom = oSld.Shapes.AddShape(msoShapeRectangle, _
Left:=0, Top:=480, Width:=720, Height:=60)
Set oTxt = oSld.Shapes.AddTextbox(msoTextOrientationHorizontal, _
Left:=0, Top:=0, Width:=720, Height:=60)
Set oTxt2 = oSld.Shapes.AddTextbox(msoTextOrientationHorizontal, _
Left:=0, Top:=494, Width:=685, Height:=50)
Set oTxt3 = oSld.Shapes.AddTextbox(msoTextOrientationHorizontal, _
Left:=0, Top:=514, Width:=685, Height:=50)
Set oPic2 = oSld.Shapes.AddPicture(FileName:=strPath & "crest.png", _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=680, _
Top:=485, _
Width:=-1, _
Height:=-1)
With oPic
If 3 * .Width > 4 * .Height Then
.Width = ActivePresentation.PageSetup.SlideWidth
.Top = 0.5 * (ActivePresentation.PageSetup.SlideHeight - .Height)
Else
.Height = ActivePresentation.PageSetup.SlideHeight
.Left = 0.5 * (ActivePresentation.PageSetup.SlideWidth - .Width)
End If
End With
With oBoxTop
.Fill.ForeColor.RGB = RGB(30, 123, 193)
.Line.ForeColor.RGB = RGB(30, 123, 193)
End With
With oBoxBottom
.Fill.ForeColor.RGB = RGB(30, 123, 193)
.Line.ForeColor.RGB = RGB(30, 123, 193)
End With
With oTxt
.TextFrame.TextRange.Text = strTemp
.TextEffect.FontName = "Palatino Linotype (Body)"
.TextEffect.Alignment = msoTextEffectAlignmentCentered
.TextEffect.FontSize = 43
.TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
'.Fill.ForeColor.RGB = RGB(30, 123, 193)
.TextFrame.TextRange.Replace Findwhat:=".jpg", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:=".png", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:=".gif", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(1)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(2)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(3)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(4)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(5)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(6)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(7)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(8)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(9)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(10)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(11)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(12)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(13)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(14)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(15)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(16)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(17)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(18)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(19)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(20)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(21)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(22)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(23)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(24)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(25)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(26)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(27)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(28)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(29)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(30)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(31)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(32)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(33)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(34)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(35)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(36)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(37)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(38)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(39)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(40)", ReplaceWhat:=""
.AnimationSettings.EntryEffect = ppEffectAppear
End With
With oTxt2
.TextFrame.TextRange.Text = "349(F)Squadron"
.TextEffect.FontName = "Palatino Linotype"
.TextEffect.Alignment = msoTextEffectAlignmentRight
.TextEffect.FontSize = 16
.TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
.TextEffect.FontItalic = msoTrue
End With
With oTxt3
.TextFrame.TextRange.Text = "Strike Hard Strike Home"
.TextEffect.FontName = "Palatino Linotype"
.TextEffect.Alignment = msoTextEffectAlignmentRight
.TextEffect.FontSize = 16
.TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
.TextEffect.FontItalic = msoTrue
End With
strTemp = Dir
Loop
strPath = ActivePresentation.Path & "\MEDIA\"
strFileSpec = "*.*"
strTemp = Dir(strPath & strEquip2 & "\" & strFileSpec)
Do While strTemp <> ""
Set oSld = ActivePresentation.Slides.Add(ActivePresentation.Slides.Count + 1, ppLayoutBlank)
Set oPic = oSld.Shapes.AddPicture(FileName:=strPath & strEquip2 & "\" & strTemp, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=0, _
Top:=0, _
Width:=-1, _
Height:=-1)
Set oBoxTop = oSld.Shapes.AddShape(msoShapeRectangle, _
Left:=0, Top:=0, Width:=720, Height:=60)
Set oBoxBottom = oSld.Shapes.AddShape(msoShapeRectangle, _
Left:=0, Top:=480, Width:=720, Height:=60)
Set oTxt = oSld.Shapes.AddTextbox(msoTextOrientationHorizontal, _
Left:=0, Top:=0, Width:=720, Height:=60)
Set oTxt2 = oSld.Shapes.AddTextbox(msoTextOrientationHorizontal, _
Left:=0, Top:=494, Width:=685, Height:=50)
Set oTxt3 = oSld.Shapes.AddTextbox(msoTextOrientationHorizontal, _
Left:=0, Top:=514, Width:=685, Height:=50)
Set oPic2 = oSld.Shapes.AddPicture(FileName:=strPath & "crest.png", _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=680, _
Top:=485, _
Width:=-1, _
Height:=-1)
With oPic
If 3 * .Width > 4 * .Height Then
.Width = ActivePresentation.PageSetup.SlideWidth
.Top = 0.5 * (ActivePresentation.PageSetup.SlideHeight - .Height)
Else
.Height = ActivePresentation.PageSetup.SlideHeight
.Left = 0.5 * (ActivePresentation.PageSetup.SlideWidth - .Width)
End If
End With
With oBoxTop
.Fill.ForeColor.RGB = RGB(30, 123, 193)
.Line.ForeColor.RGB = RGB(30, 123, 193)
End With
With oBoxBottom
.Fill.ForeColor.RGB = RGB(30, 123, 193)
.Line.ForeColor.RGB = RGB(30, 123, 193)
End With
With oTxt
.TextFrame.TextRange.Text = strTemp
.TextEffect.FontName = "Palatino Linotype (Body)"
.TextEffect.Alignment = msoTextEffectAlignmentCentered
.TextEffect.FontSize = 43
.TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
'.Fill.ForeColor.RGB = RGB(30, 123, 193)
.TextFrame.TextRange.Replace Findwhat:=".jpg", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:=".png", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:=".gif", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(1)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(2)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(3)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(4)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(5)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(6)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(7)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(8)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(9)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(10)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(11)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(12)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(13)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(14)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(15)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(16)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(17)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(18)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(19)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(20)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(21)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(22)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(23)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(24)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(25)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(26)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(27)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(28)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(29)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(30)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(31)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(32)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(33)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(34)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(35)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(36)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(37)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(38)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(39)", ReplaceWhat:=""
.TextFrame.TextRange.Replace Findwhat:="(40)", ReplaceWhat:=""
.AnimationSettings.EntryEffect = ppEffectAppear
End With
With oTxt2
.TextFrame.TextRange.Text = "349(F)Squadron"
.TextEffect.FontName = "Palatino Linotype"
.TextEffect.Alignment = msoTextEffectAlignmentRight
.TextEffect.FontSize = 16
.TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
.TextEffect.FontItalic = msoTrue
End With
With oTxt3
.TextFrame.TextRange.Text = "Strike Hard Strike Home"
.TextEffect.FontName = "Palatino Linotype"
.TextEffect.Alignment = msoTextEffectAlignmentRight
.TextEffect.FontSize = 16
.TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
.TextEffect.FontItalic = msoTrue
End With
strTemp = Dir
Loop
ActivePresentation.SlideMaster.Background.Fill.ForeColor.RGB = RGB(30, 123, 193)
End Sub
17552
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.