After searching the internet with no luck I am posting this to those much smarter than me....
I am working on a template file using Windows 7 and Excel2013. This template will be saved locally on several computers (eventually Ican see it being saved on SharePoint and used from there), but for now it will be local for multiple users.
What I need is to replace the locally saved template file if the user makes a specific change to the “template1” file (meaning that they have double clicked the template and are working with the copy). This code will be initiated by the user clicking on a button on the specific sheet that they would be changing.
I also need to do this in the background. Essentially what I am trying to do is mimic the user opening the template in “edit” mode and then saving their changes without them having to actually do this.
By using “ActiveWorkbook.SaveCopyAs” I can create a copy with their changes, but I am stuck on how to change this “.xlsm” to an “.xltm”. I have tried to do a simple rename, but the file will error out when I try toopen the template.
At the end of this I need to delete the temporary file that was created
Below is the code that I have so far.
Sub SaveTemplate()
Dim TempName As String
Dim NewName As String
Dim WBname As String
Path = "C:\Users\" & Environ("UserName") & "\Documents\Custom Office Templates\"
TempName = Left(ThisWorkbook.name, (InStrRev(ThisWorkbook.name, ".", -1, vbTextCompare) - 2))
NewName = "WTL Behavioral Assessment"
WBname = Path& TempName
ActiveWorkbook.SaveCopyAs filename:=WBname & ".xlsm"
End Sub
Thanks in advance for your help
Bookmarks