title: EXCEL VBA : Loop is working but not refreshing before printing to PDF file
body: <p>Good Morning everybody!</p>
  
  <p>I have an issue concerning my VBA Code. I actualy just want to create a loop that prints PDFs that are based on the same background template (which is in the sheet called AFFIDAVIT CREATOR) replacing some 4 boxes (labels and images) from the INPUT Sheet.</p>
  
  <p>So far, the loop is working properly. Only problem:
  It generates the PDF files according to the given name (variable r) but refreshes the sheet AFTER exporting to PDF. Result: Mutliple files with different names but they all display the same :(</p>
  
  <p>Any ideas?</p>
  
  <p>That's my code:</p>
  
  <pre><code>Private Sub TryMe()
  Dim r As Long
  Dim strCap As String
  Dim strCap2 As String
  r = 4
  
      Do Until Sheets("INPUT").Cells(r, 3).Value = ""
  
      strCap = Sheets("INPUT").Cells(r, 3).Value
      Sheets("AFFIDAVIT CREATOR").Label1.Caption = strCap
  
  strCap2 = Sheets("INPUT").Cells(r, 5).Value
  Sheets("AFFIDAVIT CREATOR").Label2.Caption = strCap2
  
  If Sheets("INPUT").Cells(r, 4) = "OE" Then
      Sheets("AFFIDAVIT CREATOR").Image1.Picture = LoadPicture(ActiveWorkbook.Path &amp; "\OE_Logo.jpg")
  Else
      Sheets("AFFIDAVIT CREATOR").Image1.Picture = LoadPicture(ActiveWorkbook.Path &amp; "\SF_Logo.jpg")
  End If
  
  If Sheets("INPUT").Cells(r, 6) = "OE" Then
      Sheets("AFFIDAVIT CREATOR").Image2.Picture = LoadPicture(ActiveWorkbook.Path &amp; "\OE_Logo.jpg")
  Else
      Sheets("AFFIDAVIT CREATOR").Image2.Picture = LoadPicture(ActiveWorkbook.Path &amp; "\SF_Logo.jpg")
  End If
  
  
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, From:=1, To:=1, FileName:=ThisWorkbook.Path &amp; "\" &amp; Sheets("INPUT").Cells(r, 3) &amp; ".pdf" _
      , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
      :=False, OpenAfterPublish:=False
  
  Sheets("AFFIDAVIT CREATOR").Calculate
  
  r = r + 1
  
  Loop
  
  End Sub
  </code></pre>