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 BigDecimal 加減乘除,四捨五入,四則運算及比較

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

java 數字轉字串 字串轉數字