writing an error routine in case it doesn't save both files

J

Janis

This macro is dangerous. It works nicely but if the file isn't there or the
name gets changed then it writes the text file to the original instead of a
copy. Can you help me write an error routine? Something like if the
original name changes or sheet1 name changes then a big error message that
this file is corrupted start over something like that?

thanks,

Sub saveIndesign()
'Appends date to filename so as to not write over an existing file

' saveIndesign Macro

Const fPath As String = "Mac OS X:"
Const fName As String = "Indesign"
Const fName1 As String = "SSP"






'do the save first as a txt file


ActiveWorkbook.SaveAs Filename:=fPath & fName & Format(Now,
"yyyymmdd_hhmmss") & ".txt"

'then save as a normal workbook or the existing file will be changed to a
text file which is not what you want

ActiveWorkbook.SaveAs Filename:=fPath & fName1 & Format(Now,
"yyyymmdd_hhmmss") & ".xls", FileFormat:=xlWorkbookNormal

MsgBox "2 Files Saved " & fName & fPath & Format(Now, "yyyymmdd_hhmmss") &
" ; " & fName1 & fPath & Format(Now, "yyyymmdd_hhmmss")



End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top