save as workday

I use the below to save files which works fine but I need to change it to save as Workday.

sFilename = "JK Daily" 'Set filename
    sPath = "C:\DATA\JKE\LSO \MI\Test\" 'Set Test base path
    If Right(sPath, 1) <> "\" Then sPath = sPath & "\" 'Check for "\"
    sPath = sPath & Format(Date, "yyyy\\mm mmm yyyy\\")
    If Dir(sPath, vbDirectory) = "" Then 'If folder doesn't exist, create it
        Shell "cmd /c mkdir """ & sPath & """"
    End If
    ActiveWorkbook.SaveAs sPath & sFilename & Format(Date - 1, " ddmmyyyy") & ".xls"


I thought it would be a case of changing the last line to :

ActiveWorkbook.SaveAs sPath & sFilename & Format(Application.WorkDay(Date, -1), "DD/MM/YYYY") & ".xls"

But this does not work.

Please assist.

Thanks
JagwarmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ProfessorJimJamCommented:
perhaps something like this

ActiveWorkbook.SaveAs sPath & sFilename & Format(WORKDAY(date,-1) " ddmmyyyy") & ".xls"
0
JagwarmanAuthor Commented:
Unfortunately that does not work. Expected List Separator so I put comma after (Date, -1) but then I got Sub or function not defined
0
Saqib Husain, SyedEngineerCommented:
Try removing the slashes from DD/MM/YYYY or replace them with hyphens
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

ProfessorJimJamCommented:
this one will work for you.  i tested it.

Sub test()


sFilename = "JK Daily" 'Set filename
    sPath = "C:\DATA\JKE\LSO \MI\Test\" 'Set Test base path
    If Right(sPath, 1) <> "\" Then sPath = sPath & "\" 'Check for "\"
    sPath = sPath & Format(Date, "yyyy\\mm mmm yyyy\\")
    If Dir(sPath, vbDirectory) = "" Then 'If folder doesn't exist, create it
        Shell "cmd /c mkdir """ & sPath & """"
    End If
    ActiveWorkbook.SaveAs sPath & sFilename & Format(Application.WorksheetFunction.WorkDay(Date, -1), " ddmmyyyy") & ".xls"



End Sub

Open in new window

0
JagwarmanAuthor Commented:
Saqib Husain, Syed thanks that works a treat and so simple.
0
JagwarmanAuthor Commented:
ProfessorJimJam that works as well thanks.
0
JagwarmanAuthor Commented:
both as good but you have to put one down as the best sorry JimJam
0
ProfessorJimJamCommented:
it is fine.  glad it worked for you.

Saqib is a very knowledgeable fellow.  I never cease to learn from others.
0
JagwarmanAuthor Commented:
I'll second that
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.