Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. deckBuilder(ServiceID,MPRPath,thisMonthFull)
  2. {
  3.     if(checkForServiceIDHelper = True)
  4.     {
  5.         Exit
  6.     }
  7.     SplashTextOn,300,200,Building Deck, Grabbing your PDF and Building your deck, please wait!
  8.    
  9.    
  10.     sleep,1000 
  11.     Try
  12.     {
  13.     ppt := ComObjCreate("PowerPoint.Application")                                      
  14.     templatePath = %MPRPath%   
  15.     ppt.Visible := true                
  16.      pptPresentation  := ppt.Presentations.Open(templatePath)                          
  17.      pptTotalSlides   := pptPresentation.Slides.Count                      
  18.                                        
  19.      ;pptHasTitle      := ppt.ActivePresentation.Slides(slideCounter).Shapes.HasTitle
  20.      ;pptSlideTitle    := Trim(ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange.Text)
  21.      
  22.      
  23.      
  24.    
  25.    
  26.      firstReplacement = Digital Advertising Performance | Ford                      ;Title we're looking for deletion
  27.      secondReplacement = Digital Advertising Performance | Lincoln                  ;Title we're looking for deletion
  28.      thirdReplacement = Website Performance Insights                                    ;Title we're looking for deletion
  29.      firstAddition = Advertising                                                     ;We'll add our first slide here
  30.      secondAddition = Website                                                        ;We'll add our second slide here
  31.      thirdAddition = Digital Strategy                                                ;We'll add our third slide here
  32.      firstImageTitle = Advertising Report
  33.      secondImageTitle = Executive Summary Report
  34.      thirdImageTitle = Quality Traffic Report
  35.      firstInsights = Advertising Insights
  36.      secondInsights = Analytics Insights
  37.      thirdInsights = Web & Design Insights
  38.     }
  39.     catch e
  40.     {
  41.         SplashTextOff
  42.         msgbox % "There was an error opening powerpoint. Please try again or report it to your administrator.`nERR: " . e
  43.         Exit
  44.     }
  45.      execSummFilePath = %A_ScriptDir%\Assets\%ServiceID%\%thisMonthFull%\%ServiceID%_1.png
  46.      trafficFilePath = %A_ScriptDir%\Assets\%ServiceID%\%thisMonthFull%\%ServiceID%_3.png                                       ;Set up slide path for later   
  47.      advertisingFilePath = %A_ScriptDir%\Assets\%ServiceID%\%thisMonthFull%\%ServiceID%_5.png  
  48.     IfNotExist, %execSummFilePath%
  49.     {
  50.         SplashTextOff
  51.         msgbox, We couldn't find your Executive Summary picture. Please run the downloader again or report it to your administrator.
  52.         exit
  53.     }
  54.     IfNotExist, %trafficFilePath%
  55.     {
  56.         SplashTextOff
  57.         msgbox, We couldn't find your Traffic Summary picture. Please run the downloader again or report it to your administrator.
  58.         exit
  59.     }
  60.     ifNotExist,%advertisingFilePath%
  61.     {
  62.         SplashTextOff
  63.         msgbox, We couldn't find your Advertising picture. Please run the downloader again or report it to your administrator.
  64.     }
  65.  
  66.     slideCounter := 1                                                                   ;Set slideCounter to 1, or we will get an out of range index err   
  67.     loop %pptTotalSlides%                                                           ;Loop through all the slides
  68.     {  
  69.         pptHasTitle := ppt.ActivePresentation.Slides(slideCounter).Shapes.HasTitle     
  70.         if(pptHasTitle= -1)                                                         ;COM returns -1 for TRUE, 0 for FALSE
  71.         {
  72.             SplashTextOff
  73.             pptDeleteSlide   := ppt.ActivePresentation 
  74.             pptSlideTitle    := Trim(ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange.Text)     ;Get title's value                                                                                              ;increment Counter
  75.             msgbox % pptSlideTitle . " counter: " . slideCounter
  76.             if (pptSlideTitle == Trim(firstReplacement) || pptSlideTitle == Trim(secondReplacement) || pptSlideTitle == Trim(thirdReplacement))
  77.             {          
  78.                 pptDeleteSlide.Slides(slideCounter).Delete
  79.                 slideCounter --            
  80.             }
  81.             else
  82.             {
  83.                 slideCounter ++
  84.             }      
  85.         }
  86.         Else                                                                                                    ;If no title, just move on
  87.         {
  88.             slideCounter ++
  89.         }
  90.         if (slideCounter = pptTotalSlides)
  91.         {
  92.             Break
  93.         }
  94.     }  
  95. ;BEGIN SLIDE ADDITIONS
  96.     slideCounter = 1
  97.     loop %pptTotalSlides%                                                           ;Loop through all the slides
  98.     {  
  99.         pptAddSlideTitle := ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange  
  100.         pptHasTitle      := ppt.ActivePresentation.Slides(slideCounter).Shapes.HasTitle
  101.         if(pptHasTitle= -1)                                                         ;COM returns -1 for TRUE, 0 for FALSE
  102.         {    
  103.             pptSlideTitle:= Trim(ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange.Text)                                    
  104.             slideCounter ++              
  105.             if (pptSlideTitle = Trim(firstAddition))
  106.             {          
  107.                 pptPresentation.Slides.Add(slideCounter,2)
  108.                 pptAddSlideTitle.Text:="Advertising Report"                          
  109.                 slideCounter ++
  110.                
  111.                 pptPresentation.Slides.Add(slideCounter,2)
  112.                 pptAddSlideTitle.Text:="Advertising Insights"                                                            
  113.                
  114.             }
  115.             else if (pptSlideTitle = Trim(secondAddition))
  116.             {                              
  117.                 pptPresentation.Slides.Add(slideCounter,2)
  118.                 pptAddSlideTitle.Text:="Executive Summary Report"                                                                                    
  119.                 slideCounter ++
  120.                
  121.                 pptPresentation.Slides.Add(slideCounter,2)
  122.                 pptAddSlideTitle.Text:="Quality Traffic Report"                            
  123.                 slideCounter ++
  124.                
  125.                 pptPresentation.Slides.Add(slideCounter,2)
  126.                 pptAddSlideTitle.Text:="Analytics Insights"                                
  127.                
  128.             }
  129.             else if (pptSlideTitle = Trim(thirdAddition))
  130.             {                                  
  131.                 pptPresentation.Slides.Add(slideCounter,2)
  132.                 pptAddSlideTitle.Text:="Web & Design Insights"               
  133.                 Break            
  134.             }
  135.         }
  136.         else
  137.         {
  138.             slideCounter ++                    
  139.         }
  140.        
  141.     }
  142. ;BEGIN IMAGE INSERTS
  143.     slideCounter = 1
  144.     loop %pptTotalSlides%                                                           ;Loop through all the slides
  145.     {  
  146.         pptShapes        := pptPresentation.Slides.Shapes  
  147.         pptHasTitle      := ppt.ActivePresentation.Slides(slideCounter).Shapes.HasTitle    
  148.         if(pptHasTitle= -1)                                                         ;COM returns -1 for TRUE, 0 for FALSE
  149.         {  
  150.             pptSlideTitle:= Trim(ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange.Text)    
  151.             slideCounter ++      
  152.             if(pptSlideTitle = Trim(firstImageTitle))
  153.             {  
  154.                 slideCounter --                        
  155.                 pptShapes.AddPicture(advertisingFilePath, True, True, 300, 125,,675)
  156.                 slideCounter ++
  157.             }
  158.             else if (pptSlideTitle = Trim(secondImageTitle))
  159.             {
  160.                 slideCounter --    
  161.                 pptShapes.AddPicture(execSummFilePath, True, True, 300, 125,,675)
  162.                 slideCounter ++
  163.             }
  164.             else if (pptSlideTitle = Trim(thirdImageTitle))
  165.             {
  166.                 slideCounter --        
  167.                 pptShapes.AddPicture(trafficFilePath, True, True, 300, 125,,675)
  168.                 slideCounter ++
  169.             }
  170.         }
  171.         else
  172.         {
  173.             slideCounter ++                    
  174.         }
  175.     }    
  176.     SplashTextOff
  177. ;BEGIN INSIGHTS  
  178.            
  179.     slideCounter = 1
  180.     loop %pptTotalSlides%                                                           ;Loop through all the slides
  181.     {  
  182.         pptSlide         := pptPresentation.Slides(slideCounter)   
  183.         pptHasTitle := ppt.ActivePresentation.Slides(slideCounter).Shapes.HasTitle 
  184.         if(pptHasTitle= -1)                                                         ;COM returns -1 for TRUE, 0 for FALSE
  185.         {  
  186.             pptSlideTitle:= Trim(ppt.ActivePresentation.Slides(slideCounter).Shapes.Title.TextFrame.TextRange.Text)        
  187.             if (pptSlideTitle = Trim(firstInsights))
  188.             {
  189.                 msgbox, Press OK to be taken to your Advertising Insights Slide.`r`nEnter your insights there and follow instructions in the following popup            
  190.                 pptSlide.Select
  191.                 slideCounter ++            
  192.             }    
  193.             else if (pptSlideTitle = Trim(secondInsights))
  194.             {
  195.                 msgbox, Press OK to be taken to your Analytics Insights Slide.`r`nEnter your insights there and follow instructions in the following popup
  196.                 pptSlide.Select
  197.                 slideCounter ++            
  198.             }
  199.             else if (pptSlideTitle = Trim(thirdInsights))
  200.             {
  201.                 msgbox, Press OK to be taken to your Web & Design Insights Slide.`r`nEnter your insights there and follow instructions in the following popup
  202.                 pptSlide.Select
  203.                 slideCounter ++
  204.                
  205.                 Break
  206.             }
  207.             else
  208.             {
  209.                 slideCounter ++
  210.             }
  211.         }
  212.        
  213.         else
  214.         {
  215.             slideCounter ++
  216.         }    
  217.     }
  218.    
  219.     MsgBox, Deck Build Complete! Please review your deck. `r`nOnce you are satisfied with it, click OK to export `r`nit as a PDF.
  220.     pptPresentation.SaveAs("""" . A_ScriptDir . "\Assets\" . ServiceID . "\" . ServiceID . "_OctoberMPR.pdf""", ppSaveAsPDF := 32) ;<-WORKING EXPORT TO PDF
  221.     ppt.Quit()
  222.     run %A_ScriptDir%\Assets\%ServiceID%\%ServiceID%_%thisMonthFull%.pdf   
  223.     Exit
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement