![]() , vbYesNo + vbQuestion, 'File Exists')On Error Resume NextIf xYesorNo = vbYes ThenKill xFolderElseMsgBox 'if you don't overwrite the existing PDF, I can't continue.' & vbCrLf & vbCrLf & 'Press OK to exit this macro.', vbCritical, 'Exiting Macro'Exit SubEnd IfIf Err.Number 0 ThenMsgBox 'Unable to delete existing file. Dear Michael,Please run the below VBA code to solve the problem.Sub SaveaspdfandsendDim xSht As WorksheetDim xFileDlg As FileDialogDim xFolder As StringDim xYesorNo As IntegerDim xOutlookObj As ObjectDim 圎mailObj As ObjectDim xUsedRng As RangeDim xStr As StringSet xSht = ActiveSheetSet xFileDlg = Application.FileDialog(msoFileDialogFolderPicker)If xFileDlg.Show = True ThenxFolder = xFileDlg.SelectedItems(1)ElseMsgBox 'You must specify a folder to save the PDF into.' & vbCrLf & vbCrLf & 'Press OK to exit this macro.', vbCritical, 'Must Specify Destination Folder'Exit SubEnd IfxStr = Format(Now, 'yyyy-mm-dd-hh-mm-ss')xFolder = xFolder + ' + xSht.Name + '-' + xStr + '.pdf'Check if file already existIf Len(Dir(xFolder)) 0 ThenxYesorNo = MsgBox(xFolder & ' already exists.' & vbCrLf & vbCrLf & 'Do you want to overwrite it?' Merge Cells/Rows/Columns without losing Data Split Cells Content Combine Duplicate Rows/Columns. Super Formula Bar (easily edit multiple lines of text and formula) Reading Layout (easily read and edit large numbers of cells) Paste to Filtered Range. Reuse: Quickly insert complex formulas, charts and anything that you have used before Encrypt Cells with password Create Mailing List and send emails. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |