help please

steve47

New Member
Joined
Aug 28, 2010
Messages
22
I found this macro code on your site and it does every thing it says it does, but i need it to do a bit more.

Private Sub Workbook_Open()

l = 0
Do
l = l + 1
lastfile = "Work book " & LTrim(Str(l)) & ".XLS"
filetest = Dir("C:\" & lastfile)
Loop Until filetest = ""

NewFileName = "C:\Work book " & LTrim(Str(l)) & ".XLS"

ActiveWorkbook.SaveAs NewFileName

End Sub

How can i make this code look for and use a "Network Drive" called P and then a sub folder called Plant Team, on my company network

The drive i need it access is called Data on totonfs01 '(P)\plant team

Please help an urgent resolution is required at my end

much regards
 
Which line of code causes the error? Can you record a macro while saving a workbook to that folder and post the VBA code?
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi And good morning

It is working but i have one request if possible.

Where it save's the file as work book 1,2,3 etc. Can it have the current date + workbook 1,2,3 etc
 
Upvote 0
Public Sub SAVE()
l = 0
Do
l = l + 1
lastfile = "Work order " & LTrim(Str(l)) & ".XLS"
filetest = Dir("\\Client\P$\Toton Plant Team\Plant team work request completed\" & lastfile)
Loop Until filetest = ""
NewFileName = "\\Client\P$\Toton Plant Team\Plant team work request completed\Work order " & LTrim(Str(l)) & ".XLS"
ActiveWorkbook.SaveAs NewFileName
End Sub

this is the working code

thanks for your help
 
Upvote 0
Try (untested):

Rich (BB code):
Public Sub SAVENEW()
    l = 0
    Do
        l = l + 1
        lastfile = "*Work order " & LTrim(Str(l)) & ".XLS"
        filetest = Dir("\\Client\P$\Toton Plant Team\Plant team work request completed\" & lastfile)
        Loop Until filetest = ""
    NewFileName = "\\Client\P$\Toton Plant Team\Plant team work request completed\" & Format(Date, "yyyymmdd") & "Work order " & LTrim(Str(l)) & ".XLS"
    ActiveWorkbook.SaveAs NewFileName
End Sub
 
Upvote 0
Hi
it works once then get message saying file all ready exsists, do u want to replace it NO. then u get run time error??

Debug high lights active workbook.saveas Newfilename

Public Sub SAVE()
l = 0
Do
l = l + 1
lastfile = "Work order " & LTrim(Str(l)) & ".XLS"
filetest = Dir("\\Client\P$\Toton Plant Team\Plant team work request completed\" & lastfile)
Loop Until filetest = ""
NewFileName = "\\Client\P$\Toton Plant Team\Plant team work request completed\" & Format(Date, "yyyymmdd") & "Work order " & LTrim(Str(l)) & ".XLS"
ActiveWorkbook.SaveAs NewFileName
End Sub

i have saved closed and reopened the file still the same

Talk tomorrow if possible as i am off duty now.

Much regard

Steve
 
Upvote 0

Forum statistics

Threads
1,216,092
Messages
6,128,782
Members
449,468
Latest member
AGreen17

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