EXCEL VBA檔案另存成PDF,另存成XLSX加密碼

 

Function saveFile_13(name, month)

Dim RS As New ADODB.Recordset

    sPath = ThisWorkbook.Path

    Sheets("13").Select

    

    Application.ScreenUpdating = False

         X="A1234567890"

        If Len(Trim(X)) > 0 Then

          

                Application.DisplayAlerts = False


                pw = Left(X, 1) & Right(X, 5)

                

                '另存成PDF

               'Sheets("13").ExportAsFixedFormat Type:=xlTypePDF, Filename:=sPath & "\" & Replace(name, "*", "") & "_" & month & "個月.pdf"

                '另存xlsx

                 Worksheets("13").Copy

                 ActiveWorkbook.SaveAs Filename:=sPath & "\" & Replace(name, "*", "") & "_" & month & "個月.xlsx", FileFormat:=xlOpenXMLWorkbook, Password:=pw

                ActiveWorkbook.Close

             Application.DisplayAlerts = True

          End If

    saveFile_13 = Replace(name, "*", "") & "_" & month & "個月.xlsx" & "," & pw

    Application.ScreenUpdating = True

End Function


留言

這個網誌中的熱門文章

java 數字轉字串 字串轉數字

MS sqlServer資料庫移轉至MySQL-->利用MySQL WorkBench

sql server 15023 error [SQL SERVER問題: 使用者、組或角色 '*****' 在當前資料庫中已存在]