Sub PDFYAP_HIZLI()
Dim yol As String
Dim dosyaAdi As String
Dim yil As String, ay As String, gun As String
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
On Error GoTo Temizle
yol = "\\DS1\ortak\DT\KİŞİŞEL KLASÖRLER\Uİ\GÜNLÜK GÖNDERİLECEK MAİLLER\"
yil = Format(Date, "yyyy")
ay = Format(Date, "mm")
gun = ActiveSheet.Name
dosyaAdi = yol & "TR - " & yil & "-" & ay & "-" & gun & ".pdf"
ActiveSheet.Range("A1:Q164").ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=dosyaAdi, _
Quality:=xlQualityMinimum, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False 'PDF açılmasın (en büyük hız artışı)
Temizle:
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub
Network yavaşsa PDF üretim süresi uzar.
Çok daha hızlı yöntem:
Önce masaüstüne oluştur → sonra kopyala
Sub PDFYAP_LokalSonraAg()
Dim ws As Worksheet
Dim masaustu As String
Dim agYolu As String
Dim dosyaAdi As String
Dim lokalDosya As String
Dim agDosya As String
Dim yil As String, ay As String, gun As String
Dim sonSatir As Long, sonSutun As Long
Set ws = ActiveSheet
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
On Error GoTo Temizle
'Masaüstü yolu
masaustu = Environ("USERPROFILE") & "\Desktop\"
' Ağ yolu
agYolu = "\\DS1\ortak\DT\KİŞİŞEL KLASÖRLER\Uİ\GÜNLÜK GÖNDERİLECEK MAİLLER\"
'Tarih bilgisi
yil = Format(Date, "yyyy")
ay = Format(Date, "mm")
gun = ws.Name
dosyaAdi = "TR - " & yil & "-" & ay & "-" & gun & ".pdf"
lokalDosya = masaustu & dosyaAdi
agDosya = agYolu & dosyaAdi
' Otomatik dolu alan
sonSatir = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
sonSutun = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
ws.PageSetup.PrintArea = ws.Range(ws.Cells(1, 1), ws.Cells(sonSatir, sonSutun)).Address
' Önce masaüstüne oluştur
ws.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=lokalDosya, _
Quality:=xlQualityMinimum, _
OpenAfterPublish:=False
' Sonra ağ klasörüne kopyala
FileCopy lokalDosya, agDosya
' İstersen masaüstündekini sil
Kill lokalDosya
Temizle:
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub