--> (Word) | --> (PDF) | --> (Epub) | |
This article has been published [fromdate] |
SCENARIO
I love the macro with the exception of one part: I don't want to be prompted to overwrite the file if it already exists. How can I change this macro so that, when pressed, it overwrites the file without prompting the user and waiting for their answer?
SOLUTION
Application.DisplayAlerts = False
Set back to True after file is saved.
EXAMPLE
Sub SaveIt() Dim strFirst As String, strLast As String ChDir "C:\Documents and Settings\All Users\Desktop\" '***************** Application.DisplayAlerts = False '***************** With Worksheets(1) strFirst = .Range("C4") strLast = .Range("C6") End With ThisWorkbook.SaveAs _ "C:\Documents and Settings\All Users\Desktop\" & _ strFirst & " -TNT- " & strLast, xlWorkbookNormal '***************** Application.DisplayAlerts = True '***************** End Sub
SOURCE | LINK (Ozgrid.com) | LANGUAGE | ENGLISH |