請幫我編輯這段代碼。我有一個Excel工作簿,我需要將它保存在我選擇的文件夾中作爲xlsm文件和PDF。在我的電子表格中添加需要輸入的所有信息以便將範圍用作參考並選擇文件保存的文件夾之後,然後出現消息框「Kon nie document stoor nie。」。彈出。如果它保存成功只有消息框「複製Gemaak」需要顯示! 感謝您的幫助!兩個消息框返回
Sub Combined()
Dim ws As Worksheet
Dim strPath As String
Dim myFile As Variant
Dim strFile As String
Dim fileSaveName As String
On Error GoTo errHandler
fileSaveName = Application.GetSaveAsFilename("Kwotasie - " & Range("H14").Value)
If VarType(fileSaveName) = vbBoolean Then Exit Sub
' Save as XLSM
ActiveWorkbook.SaveAs Filename:=fileSaveName & ".xlsm", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
' Save as PDF
Range("a1:I51").ExportAsFixedFormat Type:=xlTypePDF, Filename:=fileSaveName _
, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
If myFile <> "False" Then
ws.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
MsgBox "Copy gemaak."
End If
exitHandler:
Exit Sub
errHandler:
MsgBox "Kon nie dokumente stoor nie."
Resume exitHandler
End Sub