Page 1 of 1

สอบปัญหาการสั่งพิมพ์เป็น PDF

Posted: Tue Oct 04, 2022 3:28 pm
by tigerwit
จากไฟล์ที่แนบ
และ Code

Code: Select all

Sub index01ToPdf()
    Dim sFolderPath As String
    Dim Path As String
    Dim FName As String
    On Error Resume Next
        With ActiveSheet.PageSetup
        .Zoom = 98
    End With
    Application.ScreenUpdating = False
    
    sFolderPath = "C:\" & Range("B16").Value
    If Dir(sFolderPath, vbDirectory) = "" Then
        MkDir sFolderPath
    End If
    
    sFolderPath = "C:\" & Range("B16").Value & "\" & Range("B17").Value
    If Dir(sFolderPath, vbDirectory) = "" Then
        MkDir sFolderPath
    End If
    
    sFolderPath = "C:\" & Range("B16").Value & "\" & Range("B17").Value & "\" & "PDF"
    If Dir(sFolderPath, vbDirectory) = "" Then
        MkDir sFolderPath
    End If
    
    FName = ActiveSheet.Range("B18") & ActiveSheet.Range("B19") & ".PDF"
    Application.DisplayAlerts = False
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFolderPath & "\" & FName
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    MsgBox "บันทึกไฟล์ไว้ที่" & "C:\" & Range("B16").Value & "\" & Range("B17").Value & "\" & "PDF" & "\" & FName

End Sub
ปัญหาที่พบคือ นำไปใช้กับเครื่องหนึ่งที่เป็น วินโดว์ 11 excel 2016 ใช้ไม่ได้ มีปัญหาดังภาพ

แต่ใช้กับวินโดว์ 10 excel 2016 ใช้ได้ไม่มีปัญหา

เกิดจากสาเหตุใดครับ

Re: สอบปัญหาการสั่งพิมพ์เป็น PDF

Posted: Tue Oct 04, 2022 7:30 pm
by snasui
:D ถ้าพิมพ์แล้วมีปัญหา หมายถึงผลลัพธ์จากการพิมพ์ออกมาไม่เหมือนกับสิ่งที่แสดงบนหน้าจอครับ

สำหรับการไม่แสดงภาษาไทยหรือแสดงเป็นภาษาแปลก ๆ ของ Message Box น่าจะไม่เกี่ยวกับการพิมพ์ ลองดูการตั้งค่าภาษาได้ที่ Link นี้ครับ wordpress/macro-question-mark/