Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- deckBuilder(ServiceID,MPRPath,thisMonthFull)
- {
- if(checkForServiceIDHelper = True)
- {
- Exit
- }
- SplashTextOn,300,200,Building Deck, Grabbing your PDF and Building your deck, please wait!
- sleep,1000
- Try
- {
- ppt := ComObjCreate("PowerPoint.Application")
- templatePath = %MPRPath%
- ppt.Visible := true
- pptPresentation := ppt.Presentations.Open(templatePath)
- pptTotalSlides := pptPresentation.Slides.Count
- ;pptHasTitle := ppt.ActivePresentation.Slides(slideCounter).Shapes.HasTitle
- ;pptSlideTitle := Trim(ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange.Text)
- firstReplacement = Digital Advertising Performance | Ford ;Title we're looking for deletion
- secondReplacement = Digital Advertising Performance | Lincoln ;Title we're looking for deletion
- thirdReplacement = Website Performance Insights ;Title we're looking for deletion
- firstAddition = Advertising ;We'll add our first slide here
- secondAddition = Website ;We'll add our second slide here
- thirdAddition = Digital Strategy ;We'll add our third slide here
- firstImageTitle = Advertising Report
- secondImageTitle = Executive Summary Report
- thirdImageTitle = Quality Traffic Report
- firstInsights = Advertising Insights
- secondInsights = Analytics Insights
- thirdInsights = Web & Design Insights
- }
- catch e
- {
- SplashTextOff
- msgbox % "There was an error opening powerpoint. Please try again or report it to your administrator.`nERR: " . e
- Exit
- }
- execSummFilePath = %A_ScriptDir%\Assets\%ServiceID%\%thisMonthFull%\%ServiceID%_1.png
- trafficFilePath = %A_ScriptDir%\Assets\%ServiceID%\%thisMonthFull%\%ServiceID%_3.png ;Set up slide path for later
- advertisingFilePath = %A_ScriptDir%\Assets\%ServiceID%\%thisMonthFull%\%ServiceID%_5.png
- IfNotExist, %execSummFilePath%
- {
- SplashTextOff
- msgbox, We couldn't find your Executive Summary picture. Please run the downloader again or report it to your administrator.
- exit
- }
- IfNotExist, %trafficFilePath%
- {
- SplashTextOff
- msgbox, We couldn't find your Traffic Summary picture. Please run the downloader again or report it to your administrator.
- exit
- }
- ifNotExist,%advertisingFilePath%
- {
- SplashTextOff
- msgbox, We couldn't find your Advertising picture. Please run the downloader again or report it to your administrator.
- }
- slideCounter := 1 ;Set slideCounter to 1, or we will get an out of range index err
- loop %pptTotalSlides% ;Loop through all the slides
- {
- pptHasTitle := ppt.ActivePresentation.Slides(slideCounter).Shapes.HasTitle
- if(pptHasTitle= -1) ;COM returns -1 for TRUE, 0 for FALSE
- {
- SplashTextOff
- pptDeleteSlide := ppt.ActivePresentation
- pptSlideTitle := Trim(ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange.Text) ;Get title's value ;increment Counter
- msgbox % pptSlideTitle . " counter: " . slideCounter
- if (pptSlideTitle == Trim(firstReplacement) || pptSlideTitle == Trim(secondReplacement) || pptSlideTitle == Trim(thirdReplacement))
- {
- pptDeleteSlide.Slides(slideCounter).Delete
- slideCounter --
- }
- else
- {
- slideCounter ++
- }
- }
- Else ;If no title, just move on
- {
- slideCounter ++
- }
- if (slideCounter = pptTotalSlides)
- {
- Break
- }
- }
- ;BEGIN SLIDE ADDITIONS
- slideCounter = 1
- loop %pptTotalSlides% ;Loop through all the slides
- {
- pptAddSlideTitle := ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange
- pptHasTitle := ppt.ActivePresentation.Slides(slideCounter).Shapes.HasTitle
- if(pptHasTitle= -1) ;COM returns -1 for TRUE, 0 for FALSE
- {
- pptSlideTitle:= Trim(ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange.Text)
- slideCounter ++
- if (pptSlideTitle = Trim(firstAddition))
- {
- pptPresentation.Slides.Add(slideCounter,2)
- pptAddSlideTitle.Text:="Advertising Report"
- slideCounter ++
- pptPresentation.Slides.Add(slideCounter,2)
- pptAddSlideTitle.Text:="Advertising Insights"
- }
- else if (pptSlideTitle = Trim(secondAddition))
- {
- pptPresentation.Slides.Add(slideCounter,2)
- pptAddSlideTitle.Text:="Executive Summary Report"
- slideCounter ++
- pptPresentation.Slides.Add(slideCounter,2)
- pptAddSlideTitle.Text:="Quality Traffic Report"
- slideCounter ++
- pptPresentation.Slides.Add(slideCounter,2)
- pptAddSlideTitle.Text:="Analytics Insights"
- }
- else if (pptSlideTitle = Trim(thirdAddition))
- {
- pptPresentation.Slides.Add(slideCounter,2)
- pptAddSlideTitle.Text:="Web & Design Insights"
- Break
- }
- }
- else
- {
- slideCounter ++
- }
- }
- ;BEGIN IMAGE INSERTS
- slideCounter = 1
- loop %pptTotalSlides% ;Loop through all the slides
- {
- pptShapes := pptPresentation.Slides.Shapes
- pptHasTitle := ppt.ActivePresentation.Slides(slideCounter).Shapes.HasTitle
- if(pptHasTitle= -1) ;COM returns -1 for TRUE, 0 for FALSE
- {
- pptSlideTitle:= Trim(ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange.Text)
- slideCounter ++
- if(pptSlideTitle = Trim(firstImageTitle))
- {
- slideCounter --
- pptShapes.AddPicture(advertisingFilePath, True, True, 300, 125,,675)
- slideCounter ++
- }
- else if (pptSlideTitle = Trim(secondImageTitle))
- {
- slideCounter --
- pptShapes.AddPicture(execSummFilePath, True, True, 300, 125,,675)
- slideCounter ++
- }
- else if (pptSlideTitle = Trim(thirdImageTitle))
- {
- slideCounter --
- pptShapes.AddPicture(trafficFilePath, True, True, 300, 125,,675)
- slideCounter ++
- }
- }
- else
- {
- slideCounter ++
- }
- }
- SplashTextOff
- ;BEGIN INSIGHTS
- slideCounter = 1
- loop %pptTotalSlides% ;Loop through all the slides
- {
- pptSlide := pptPresentation.Slides(slideCounter)
- pptHasTitle := ppt.ActivePresentation.Slides(slideCounter).Shapes.HasTitle
- if(pptHasTitle= -1) ;COM returns -1 for TRUE, 0 for FALSE
- {
- pptSlideTitle:= Trim(ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange.Text)
- if (pptSlideTitle = Trim(firstInsights))
- {
- msgbox, Press OK to be taken to your Advertising Insights Slide.`r`nEnter your insights there and follow instructions in the following popup
- pptSlide.Select
- slideCounter ++
- }
- else if (pptSlideTitle = Trim(secondInsights))
- {
- msgbox, Press OK to be taken to your Analytics Insights Slide.`r`nEnter your insights there and follow instructions in the following popup
- pptSlide.Select
- slideCounter ++
- }
- else if (pptSlideTitle = Trim(thirdInsights))
- {
- msgbox, Press OK to be taken to your Web & Design Insights Slide.`r`nEnter your insights there and follow instructions in the following popup
- pptSlide.Select
- slideCounter ++
- Break
- }
- else
- {
- slideCounter ++
- }
- }
- else
- {
- slideCounter ++
- }
- }
- MsgBox, Deck Build Complete! Please review your deck. `r`nOnce you are satisfied with it, click OK to export `r`nit as a PDF.
- pptPresentation.SaveAs("""" . A_ScriptDir . "\Assets\" . ServiceID . "\" . ServiceID . "_OctoberMPR.pdf""", ppSaveAsPDF := 32) ;<-WORKING EXPORT TO PDF
- ppt.Quit()
- run %A_ScriptDir%\Assets\%ServiceID%\%ServiceID%_%thisMonthFull%.pdf
- Exit
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement