1

Disclaimer: I've read the relevant questions/answers regarding Error 1004 and I couldn't find a solution.

I have a macro that I distributed within the team and it works perfectly on all computers (including mine) except one. She's running the same version of Excel on the same system and she can use other macros except this one, I get the "Error 1004 SaveAs function failed" message. It is by a very long shot but did I miss some security setting or is there some problem with the code that could cause this? This is the code in question:

Sub PSSaveFile()
Dim myVal2 As Variant
Dim myValn2 As String
Dim myDate As String
Dim mFilePath As String

myVal2 = InputBox("Please enter today's date in mm-dd format")
myValn2 = Replace(myVal2, "-", "\")
myDate = Date

mFilePath = "\\xxxxxxxx003\xxx_emea\TCU_REPORTS\APPS\Reports\Regional\xxxxx for PC  Web xx\2017\" & myValn2

ActiveWorkbook.SaveAs FileName:=mFilePath & "\xxxRHLogs-" & myDate & "_checked"
End Sub
Rhyfelwr
  • 299
  • 2
  • 5
  • 19
  • 1
    Do you checked permission of that shared folder from that computer? – Harun24hr Nov 30 '17 at 14:58
  • 1
    Good point! Unfortunately we are all working on a shared drive and the permissions are adjusted externally so we all have the same access. – Rhyfelwr Nov 30 '17 at 14:59
  • the user has to manually enter today's date?? Have you tried Googling your issue? – ashleedawg Nov 30 '17 at 15:08
  • As you can see our folder path is generated daily `xxx/2017/11/30` The manual date entry is for the macro to find the corresponding folder. As we are working with backdating data manual date entry is a must so that we can interact with folders from older dates. – Rhyfelwr Nov 30 '17 at 15:11

1 Answers1

1

Let me guess - the guy with the other computer is from another country, thus using his own regional settings on the PC. Thus the date format is a bit fancier, e.g. dd/mm/yyyy and it is not allowed to save it as a file because of this.

Try to change the date like this:

myDate = year(date) & month(date) & day(date)

and try again. This would eliminate the fancy settings part.

Vityata
  • 42,633
  • 8
  • 55
  • 100
  • Dont forget that it could also be another OS in which case the path separator could be an issue as well. – Brandon Barney Nov 30 '17 at 15:03
  • 1
    Amazing! Yes indeed she had US date format while we use the EU format. I adjusted the code according to her system date and now the macro works perfectly. I'd have never thought of that. Thank you so much! @BrandonBarney yeah my question was a tad bit generic I admit it :) – Rhyfelwr Nov 30 '17 at 15:09
  • @Rhyfelwr - there is always this one person at the office. :) (In my office it is me) :D – Vityata Nov 30 '17 at 15:34