I got the following code a long time ago and if worked perfectly for the workbook that it related too however I have tried to use it in another workbook and instead of adding a number to the filename it is adding .xls, so if the file exists it ends up as i.e. testbook.xls.xls whereas it should be testbook2.xls, any help would be appreciated.
original code:
adapted code
textbox27 is the activeworkbook name including .xls
I tried to remove the .xls but it ends up as .xls1.xls
original code:
Code:
Dim n As Integer
Dim filename As String
n = 0
Do
filename = "C:\Temp Forms\Xtemplate" & IIf(n = 0, "", n) & ".xls"
n = n + 1
Loop Until Dir(filename) = ""
ActiveWorkbook.SaveAs filename
adapted code
textbox27 is the activeworkbook name including .xls
I tried to remove the .xls but it ends up as .xls1.xls
Code:
Dim n As Integer
Dim filename As String
n = 0
Do
filename = "H:\" & textbox27.value & IIf(n = 0, "", n) & ".xls"
n = n + 1
Loop Until Dir(filename) = ""
ActiveWorkbook.SaveAs filename