SaveCopyAs runtime error

rudfaden

New Member
Joined
Feb 5, 2011
Messages
48
When i use the following code in Excel 2011 for Mac i get runtime Error 1004.

Does anyone have an idea to fix it?

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Msg As String
Dim Ans As Integer
Dim FName As String
Msg = “Would you like to make a backup of this file?”
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbYes Then
FName = "Rud's HD:Users:RudVFaden:Backup:” & ThisWorkbook.Name
ThisWorkbook.SaveCopyAs FName
End If
End Sub
 

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,197
Is it really the case that colons ( : ) are supposed to be there, and not the folder separation character " / " ?? If not, please clue us in as to which line is the offending code.
 

rudfaden

New Member
Joined
Feb 5, 2011
Messages
48
Hi.

Thanks for your fast reply. I think semicolon is the right thing to use. At least this is what i was able find on the web. It also works fine with the FileLen function.

The error i cused by the line
Code:
ThisWorkbook.SaveCopyAs FName
 

Forum statistics

Threads
1,081,527
Messages
5,359,295
Members
400,524
Latest member
Excelbat

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top