สอบถามการ SetPrintArea ครับ
จากไฟล์ ผมต้องการสั่งบันทึกPDF ตาราง ในชีท รายงาน
แต่จากข้อมูลที่รายงานออกมา มีไม่เท่ากัน
ผมต้องการตัดตารางส่วนที่ว่างออก ก่อนพิมพ์
ผมลองเขียนโค้ด สองแบบ ครับ
สั่งบันทึก PDF ได้แล้ว ติดปัญหาไม่ตัดตารางส่วนที่ว่าง ครับ
Code: Select all
Sub Printrang()
Dim Print_Area As String
Sheets("รายงาน").Select
Print_Area = Range("b1", Range("b" & Rows.Count).End(xlUp).Offset(0, 6)).Address
ActiveSheet.PageSetup.PrintArea = Print_Area
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\" & Range("F1").Value & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, OpenAfterPublish:=True
End Sub
Code: Select all
Sub SetPrintAreaSetPrintAreaBeforePrint()
Dim i As Integer
Dim lng As Long
lng = Rows.Count
i = Range("B" & lng).End(xlUp).Row
ActiveSheet.PageSetup.PrintArea = "$A$2:$G$" & i
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\" & Range("F1").Value & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, OpenAfterPublish:=True
End Sub
You do not have the required permissions to view the files attached to this post.