creating workbook

MAMIBUSSOL

Board Regular
Joined
Jun 2, 2011
Messages
95
I use this code to create a new workbook

Code:
Sub ABBOTS()
    Workbooks.Add
    ChDir "C:\Documents and Settings\Admin\Desktop"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\Admin\Desktop\WAGES.xls", FileFormat:=xlExcel8, _
        Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
        CreateBackup:=False
End Sub

if the file doesn't exist, works as planned, however if the file being created exists I get a replace error message, Is there any way to just create the file without user entry
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try either switching the warnings off or look to delete the workbook first with a Kill statement

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> CheckBook1()<br>Application.DisplayAlerts = <SPAN style="color:#00007F">False</SPAN><br><SPAN style="color:#007F00">'Your code</SPAN><br><br>Application.DisplayAlerts = <SPAN style="color:#00007F">True</SPAN><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
Try

Code:
Sub ABBOTS()
    Workbooks.Add
    ChDir "C:\Documents and Settings\Admin\Desktop"
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\Admin\Desktop\WAGES.xls", FileFormat:=xlExcel8, _
        Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
        CreateBackup:=False
    Application.DisplayAlerts = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,441
Messages
6,166,049
Members
452,009
Latest member
oishi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top