So I created a workaround so that I can make updates to a workbook so that the end user is always using the latest version. I did this by having the "Master" workbook save a copy to the user's desktop upon opening (Name for the desktop copy of the workbook ends in "Desktop"). The user is then working with the version on their desktop instead of the "Master". What I am trying to do now, is write some code so that the desktop copy is deleted upon exiting the workbook. Here is the code that executes upon opening:
Here is my attempt at the code for when the workbook is closed:
If someone could help me solve this I would really appreciate it!
Bonus question: Is there a way to preface these codes with an if statement so that if the workbook is located in my files it disables the macros? lol. This code is difficult to work because it keeps executing when I am working with it. It's like working with a wet bar of soap. haha
VBA Code:
Private Sub Workbook_Open()
Dim Path As String
Path = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & "Journal Entry Automator Desktop.xls"
If Dir(Path) <> "" Then Kill (Path)
ActiveWorkbook.SaveAs Path
End Sub
Here is my attempt at the code for when the workbook is closed:
VBA Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ThisWorkbook.Name = "Journal Entry Automator Desktop.xlsm" Then
ThisWorkbook.ChangeFileAccess xlReadOnly
Kill ThisWorkbook.FullName
End If
End Sub
If someone could help me solve this I would really appreciate it!
Bonus question: Is there a way to preface these codes with an if statement so that if the workbook is located in my files it disables the macros? lol. This code is difficult to work because it keeps executing when I am working with it. It's like working with a wet bar of soap. haha