EXCEL TOOLS
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
[code]
และปิดด้วย [/code]
ตัวอย่างเช่น [code]dim r as range[/code]
เพื่อให้แตกต่างจากข้อความทั่วไป สะดวกในการอ่านและทดสอบ (คลิกเพื่อดูตัวอย่าง)Code: Select all
Sub printpdf()
Dim sFolderPath As String
Dim FName As String
Dim fdObj As Object
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set fdObj = CreateObject("Scripting.FileSystemObject")
fdObj.CreateFolder ("C:\" & Range("A2").Value)
sFolderPath = "C:\" & Range("A2").Value
FName = Range("A1").Value & ".PDF"
' If Sheet1.Range("J1").Value > 38 Then
Sheets(Array("sheet2", "sheet3", "sheet4", "sheet5", "sheet6")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFolderPath & "\" & FName
Sheet1.Select
' End If
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Print OK"
End Sub
Code: Select all
Sub printpdf()
Dim sFolderPath As String
Dim FName As String
Dim fdObj As Object
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set fdObj = CreateObject("Scripting.FileSystemObject")
fdObj.CreateFolder ("C:\" & Range("A2").Value)
sFolderPath = "C:\" & Range("A2").Value
FName = Range("A1").Value & ".PDF"
If Sheet1.Range("J1").Value > 38 Then
Sheets(Array("sheet2", "sheet3", "sheet4", "sheet5", "sheet6")).Select
Else
With Sheets("Sheet2")
With .PageSetup
.PrintArea = "A2:J38"
.FitToPagesTall = 1
End With
.Select
End With
End If
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFolderPath & "\" & FName
Sheet1.Select
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Print OK"
End Sub