Macro to save contents of a named range to a file
Gord and Garry,
Initially, if the file I was writing to already existed, the macro
would cause the following dialog message prompt to appear:
"A filename 'C:\Temp\TEST.txt already exists in this location.
Do you want to replace it ?"
After inserting the "Application.DisplayAlerts = False" line, I've
verified the macro successfully overwrites the existing file -
effectively dismissing the overwrite prompt.
Here is the code:
Sub Macro_SaveAs_File()
'
' Macro_SaveAs_File Macro
'
'
Application.Goto Reference:="DATA"
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="C:\Temp\TEST.txt",
FileFormat:=xlText, _
CreateBackup:=False
Application.DisplayAlerts = True
End Sub
Thanks for the help Gord.
- Ronald K.
|