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.DisplayAler