- Katılım
- 11 Mart 2005
- Mesajlar
- 3,111
- Excel Vers. ve Dili
- Office 2013 İngilizce
Merhaba,
Aşağıdaki kod ile Excel sayfasını PDF olarak kayıt ederken, sadece 1. sayfayı kayıt yapması,
2. sayfada hiç veri yokken PDF' i 2 sayfa olarak oluşturuyor, Excel de 2. sayfaya veri taşsa bile sadece ilk sayfayı olarak PDF oluştursun istiyorum.
ilginize şimdiden teşekkürler,
iyi akşamlar.
Aşağıdaki kod ile Excel sayfasını PDF olarak kayıt ederken, sadece 1. sayfayı kayıt yapması,
2. sayfada hiç veri yokken PDF' i 2 sayfa olarak oluşturuyor, Excel de 2. sayfaya veri taşsa bile sadece ilk sayfayı olarak PDF oluştursun istiyorum.
ilginize şimdiden teşekkürler,
Kod:
Sub PDFActiveSheet()
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strTime As String
Dim strName As String
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
On Error GoTo errHandler
Set wbA = ActiveWorkbook
Set wsA = ActiveSheet
strTime = Format(Now(), "yyyymmdd\_hhmm")
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & "\"
strName = Replace(wsA.Name, " ", "")
strName = Replace(strName, ".", "_")
strFile = strName & "_" & strTime & ".pdf"
strPathFile = strPath & strFile
myFile = Application.GetSaveAsFilename _
(InitialFileName:=strPathFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If myFile <> "False" Then
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
MsgBox "PDF file has been created: " _
& vbCrLf _
& myFile
End If
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not create PDF file"
Resume exitHandler
End Sub
iyi akşamlar.