title: Transform pptx file to jpg with VBA
body: <p>I have a folder full of pptx files, and a code base that generates pptx files from a table in excel, via VBA, I need to put in this code a step in which I transform the pptx file into jpg, it can be after creating the file or during, follow code below</p>
  <pre><code>Option Explicit
  
  Public Sub GerarPPTS()
  
      Dim tb As ListObject 'ListObject é uma tabela
      Dim Linha As ListRow
      
      Dim ppt             As Object 'PowerPoint.Application
      Dim apresentacao As Object 'PowerPoint.Presentation
      Dim slide       As Object 'PowerPoint.slide
      Dim sp          As Object 'PowerPoint.Shape
      
      'Set o objeto Tabela que é Objeto de lista
      Set tb = wsInicio.ListObjects(&quot;tbPEssoas&quot;)
      
      'Gerar um PPT APLICAÇÂo
      Set ppt = CreateObject(&quot;Powerpoint.Application&quot;) 'ew PowerPoint.Application
      ppt.Visible = True
           
      'Loopar as linhas da tabela
      For Each Linha In tb.ListRows
          
           'Criando uma Apresentação
           'Baseada num modelo
           Set apresentacao = ppt.Presentations.Open(ThisWorkbook.Path &amp; &quot;\ANIVERSARIANTE Auto.pptx&quot;)
          'Loopar os Slides trocando as variaveis
          'do PPT pelos valores do Excel
      
          'Tenta alterar o texto de TODOS
          'os shapes e se der erro continua
          On Error Resume Next
          For Each slide In apresentacao.Slides
              For Each sp In slide.Shapes
                  sp.TextFrame.TextRange.Text = VBA.Replace(sp.TextFrame.TextRange.Text, &quot;@NOME&quot;, Linha.Range(1, 1))
                  sp.TextFrame.TextRange.Text = VBA.Replace(sp.TextFrame.TextRange.Text, &quot;@DATA&quot;, Linha.Range(1, 2))
              
              Next sp
          Next slide
          'Desliga o tratamento de erro malucop
          On Error GoTo 0
          
          'SALVA O ARQUIVO NO LUGAR DESEJADO
          apresentacao.SaveCopyAs ThisWorkbook.Path &amp; &quot;\&quot; &amp; Linha.Range(1, 1) &amp; &quot;.pptx&quot;
          VBA.DoEvents
      Next Linha
     
      'FECHA O POWERPOINT
      ppt.Quit
      Set ppt = Nothing
      
  End Sub
  </code></pre>