EXCEL VBA: Loop funciona pero no se actualiza antes de imprimir en un archivo PDF
¡Buenos dias a todos!
Tengo un problema relacionado con mi código VBA. En realidad, solo quiero crear un bucle que imprima archivos PDF que se basen en la misma plantilla de fondo (que se encuentra en la hoja llamada AFFIDAVIT CREATOR) reemplazando algunas 4 cajas (etiquetas e imágenes) de la Hoja de ENTRADA.
Hasta ahora, el bucle está funcionando correctamente. Solo problema: genera los archivos PDF de acuerdo con el nombre dado (variable r) pero actualiza la hoja DESPUÉS de exportar a PDF. Resultado: los archivos Mutliple con nombres diferentes, pero todos muestran el mismo :(
¿Algunas ideas?
Ese es mi código:
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 & "\OE_Logo.jpg")
Else
Sheets("AFFIDAVIT CREATOR").Image1.Picture = LoadPicture(ActiveWorkbook.Path & "\SF_Logo.jpg")
End If
If Sheets("INPUT").Cells(r, 6) = "OE" Then
Sheets("AFFIDAVIT CREATOR").Image2.Picture = LoadPicture(ActiveWorkbook.Path & "\OE_Logo.jpg")
Else
Sheets("AFFIDAVIT CREATOR").Image2.Picture = LoadPicture(ActiveWorkbook.Path & "\SF_Logo.jpg")
End If
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, From:=1, To:=1, FileName:=ThisWorkbook.Path & "\" & Sheets("INPUT").Cells(r, 3) & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Sheets("AFFIDAVIT CREATOR").Calculate
r = r + 1
Loop
End Sub