austenr
11-12-2004, 11:36 AM
I want to put this code in the UserForm to ask the user to save the file as: and then pick a name. If the file already exists delete it. Will this work? I have attached my zip file for your consideration. Thanks in advance:
Dim fName As String, FileNm As String
'GET THE NEW FILENAME FROM THE CURRENT SHEET
FileNm = ActiveSheet.Range("H1").Value & ActiveSheet.Range("I1").Value
fName = ActiveWorkbook.Path & "\" & FileNm & ".xls"
Debug.Print fName
'IF THE FILE ALREADY EXISTS THEN DELETE IT ---------------------------------*
If Dir(fName) <> "" Then Kill fName
'COPY THE WORKSHEET
ThisWorkbook.ActiveSheet.Copy
'SAVE THE NEW WORKBOOK
ActiveWorkbook.SaveAs Filename:=fName
ActiveWorkbook.Close
Dim fName As String, FileNm As String
'GET THE NEW FILENAME FROM THE CURRENT SHEET
FileNm = ActiveSheet.Range("H1").Value & ActiveSheet.Range("I1").Value
fName = ActiveWorkbook.Path & "\" & FileNm & ".xls"
Debug.Print fName
'IF THE FILE ALREADY EXISTS THEN DELETE IT ---------------------------------*
If Dir(fName) <> "" Then Kill fName
'COPY THE WORKSHEET
ThisWorkbook.ActiveSheet.Copy
'SAVE THE NEW WORKBOOK
ActiveWorkbook.SaveAs Filename:=fName
ActiveWorkbook.Close