nigelandrewfoster
Well-known Member
- Joined
- May 27, 2009
- Messages
- 747
The code below stops with the error "Runtime error 1004: Cannot access THURSDAY 10.5.12.xls" at the red line. The workbook of that name already exists in that folder, and should prompt me whether I want to save over it or not (as a similar macro I have used for years did) but stops with this error. Anyone know why, please? Thanks for your time.
Nigel
Nigel
Code:
Sub GetSOInfo()
Dim so As Worksheet, f As Worksheet, ri As Range, cel As Range, col As Range, day As Integer, DateInc As Integer
Dim c As Integer, p As Integer, a, OldDate As String, NewDate As String
Dim dte As Date, dc As String, dp As String
dte = Worksheets("Workpad").[b10]
If WorksheetFunction.Weekday(dte) = 7 Then
DateInc = 2
Else
DateInc = 1
End If
OldDate = UCase(WorksheetFunction.Text(dte, "DDDD")) & " " & WorksheetFunction.Text(dte, "D.M.Y")
NewDate = UCase(WorksheetFunction.Text(dte + DateInc, "DDDD")) & " " & WorksheetFunction.Text(dte + DateInc, "D.M.Y")
If MsgBox("Do you want to set up the standing order figures for " & NewDate & "?" & vbCr & vbCr & _
"THIS WILL CLEAR ALL EXISTING FIGURES FROM THE ORDER SHEET", vbYesNo, "ARE YOU SURE?") = vbNo Then Exit Sub
Application.ScreenUpdating = False
[COLOR="Red"]ActiveWorkbook.SaveAs Filename:="\\Think\c\NICE BUNS\NICE BUNS BAKERY\ORDERS\DAILY ORDERS\" & OldDate & ".xls"[/COLOR]
MsgBox OldDate & " saved sucessfully"
.....etc
Last edited: