I have some VBA code which I would really like to run after I close excel.
I was wondering if there was a way to paste this into a text file and save as a vb filetype, then I could just run it whenever I wanted to.
I believe the method I am using to copy the files is not dependant on the excel application...
The code simply backs up my toolbar and personal macro workbook. But, the toolbar file (excel11.xlb) doesnt get updated until you close excel.
Currently, I have to close excel, then open it back up, then run this macro to get the most up to date files.
So, how would I go about making this code executable outside of the excel application.
I was wondering if there was a way to paste this into a text file and save as a vb filetype, then I could just run it whenever I wanted to.
I believe the method I am using to copy the files is not dependant on the excel application...
The code simply backs up my toolbar and personal macro workbook. But, the toolbar file (excel11.xlb) doesnt get updated until you close excel.
Currently, I have to close excel, then open it back up, then run this macro to get the most up to date files.
So, how would I go about making this code executable outside of the excel application.
Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub backupWorkspaceFiles()
'''''''''''''''''''''''''
Dim PERSONAL As Object
Dim ExceL11 As Object
Dim strDate As String
Dim strPersDir As String
Dim strExcDir As String
Dim strNewDir As String
Dim strNewPers As String
Dim strNewExc As String
'''''''''''''''''''''''''
strDate = Format((Date), "YYYY-MM-DD")
strPersDir = "C:\Documents and Settings\MYuserNAME\Application Data\Microsoft\Excel\XLSTART"
strExcDir = "C:\Documents and Settings\MYuserNAME\Application Data\Microsoft\Excel\"
strNewDir = "\\MYDIR\MY FILES\EXCEL WORKSPACE FILES"
strNewPers = "(" & strDate & ")" & "PERSONAL.xls"
strNewExc = "(" & strDate & ")" & "Excel11.xlb"
Set PERSONAL = CreateObject("Scripting.FileSystemObject")
Set ExceL11 = CreateObject("Scripting.FileSystemObject")
'''''''''''''''''''''''''
'object.copyfile,source,destination,file overright(True is default)
PERSONAL.CopyFile strPersDir & "\" & "PERSONAL.xls", strNewDir & "\" & strNewPers, True
ExceL11.CopyFile strExcDir & "\" & "Excel11.xlb", strNewDir & "\" & strNewExc, True
Set PERSONAL = Nothing
Set ExceL11 = Nothing
'''''''''''''''''''''''''
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Last edited: