|
Sub 导出为pdf文件() 'qs2024/7/5
Application.ScreenUpdating = False: Application.DisplayAlerts = False
Dim strPatph As String
'判断当前文件路径是否有成绩的文件夹,没有就创建,有就反馈一下路径=============
Set fso = CreateObject("Scripting.FileSystemObject")
folderPath = ThisWorkbook.Path & "\成绩\" '设置你想要检查的文件夹路径
If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\" '确保路径以反斜杠结束
'尝试获取文件夹对象
On Error Resume Next
Set folder = fso.GetFolder(folderPath)
If Err.Number <> 0 Then
'如果文件夹不存在,则创建文件夹
fso.CreateFolder folderPath
MsgBox "文件夹已创建: " & folderPath
Else
'文件夹已存在
MsgBox "文件夹已存在: " & folderPath
End If
On Error GoTo 0 ' 重置错误处理
'判断当前文件路径是否有成绩的文件夹,没有就创建,有就反馈一下路径=============
ThisWorkbook.ActiveSheet.Copy
strpath = ThisWorkbook.Path & "\成绩\"
s = InputBox("请输入导出文件名:", "输入提示", "2024年上期期末教学质量监测学生成绩册()")
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strpath & s & ".pdf"
ActiveWindow.Close
Set folder = Nothing
Set fso = Nothing
Application.ScreenUpdating = True: Application.DisplayAlerts = True
End Sub |
|