ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Backup Addin (https://www.excelbanter.com/excel-programming/419842-backup-addin.html)

Robin Clay[_4_]

Backup Addin
 
Greetings !

I have this little routine in my AddIn, to save it on exit - Gord Dibben may
recognise this (for which, thanks again)

But as well as saving the AddIn, I would like to save a copy of it. But
this doesn't work....
-----------------
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim Msg, Ans, myDate, MyNew

With ActiveWorkbook
Msg = "Do You Want Save Changes to " _
& Me.Name & "?"
Ans = MsgBox(Msg, vbQuestion + vbYesNoCancel)
Select Case Ans
Case vbYes
Me.Save
myDate = Mid(Me.UserStatus(1, 2), 7, 4) _
& Mid(Me.UserStatus(1, 2), 4, 2) _
& Mid(Me.UserStatus(1, 2), 1, 2) _
& Mid(Me.UserStatus(1, 2), 12, 2) _
& Mid(Me.UserStatus(1, 2), 15, 2)
MyNew = Left(Me.Name, Len(Me.Name) - 4) _
& " " & myDate _
& ".xla"
FileCopy Me.Name = MyNew '<-------- doesn't work !
Case vbNo
Me.Saved = True
Case vbCancel
Cancel = True
Exit Sub
End Select
End With
End Sub
-----------------

Regards

Robin

Bob Phillips

Backup Addin
 
Try savecopyas

Me.SaveCopyAs MyNew


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Robin Clay" <Robin_B DOT Clay AT virgin DOT net wrote in message
...
Greetings !

I have this little routine in my AddIn, to save it on exit - Gord Dibben
may
recognise this (for which, thanks again)

But as well as saving the AddIn, I would like to save a copy of it. But
this doesn't work....
-----------------
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim Msg, Ans, myDate, MyNew

With ActiveWorkbook
Msg = "Do You Want Save Changes to " _
& Me.Name & "?"
Ans = MsgBox(Msg, vbQuestion + vbYesNoCancel)
Select Case Ans
Case vbYes
Me.Save
myDate = Mid(Me.UserStatus(1, 2), 7, 4) _
& Mid(Me.UserStatus(1, 2), 4, 2) _
& Mid(Me.UserStatus(1, 2), 1, 2) _
& Mid(Me.UserStatus(1, 2), 12, 2) _
& Mid(Me.UserStatus(1, 2), 15, 2)
MyNew = Left(Me.Name, Len(Me.Name) - 4) _
& " " & myDate _
& ".xla"
FileCopy Me.Name = MyNew '<-------- doesn't work !
Case vbNo
Me.Saved = True
Case vbCancel
Cancel = True
Exit Sub
End Select
End With
End Sub
-----------------

Regards

Robin




Robin Clay[_4_]

Backup Addin
 
Thank you !
--
Regards

Robin


"Bob Phillips" wrote:

Try savecopyas

Me.SaveCopyAs MyNew


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Robin Clay" <Robin_B DOT Clay AT virgin DOT net wrote in message
...
Greetings !

I have this little routine in my AddIn, to save it on exit - Gord Dibben
may
recognise this (for which, thanks again)

But as well as saving the AddIn, I would like to save a copy of it. But
this doesn't work....
-----------------
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim Msg, Ans, myDate, MyNew

With ActiveWorkbook
Msg = "Do You Want Save Changes to " _
& Me.Name & "?"
Ans = MsgBox(Msg, vbQuestion + vbYesNoCancel)
Select Case Ans
Case vbYes
Me.Save
myDate = Mid(Me.UserStatus(1, 2), 7, 4) _
& Mid(Me.UserStatus(1, 2), 4, 2) _
& Mid(Me.UserStatus(1, 2), 1, 2) _
& Mid(Me.UserStatus(1, 2), 12, 2) _
& Mid(Me.UserStatus(1, 2), 15, 2)
MyNew = Left(Me.Name, Len(Me.Name) - 4) _
& " " & myDate _
& ".xla"
FileCopy Me.Name = MyNew '<-------- doesn't work !
Case vbNo
Me.Saved = True
Case vbCancel
Cancel = True
Exit Sub
End Select
End With
End Sub
-----------------

Regards

Robin






All times are GMT +1. The time now is 06:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com