I seem to be experiencing an odd issue when saving a template file with a new name.
I have a template file (not saved as a 'template' file though) and I need to run a loop through some names to create a file for each person using the template.
I have run this kind process before on SharePoint but it seems to be acting oddly now.
Basically, the code opens the template, plugs in some data and then it should save it in another folder with a new file name. It does do this, but the original template file has all the data added to the newly created file.
The above repeats x times but when the wbTemplate is opened 2nd time round it is the same as the file saved in the different folder.
TIA
I have a template file (not saved as a 'template' file though) and I need to run a loop through some names to create a file for each person using the template.
I have run this kind process before on SharePoint but it seems to be acting oddly now.
Basically, the code opens the template, plugs in some data and then it should save it in another folder with a new file name. It does do this, but the original template file has all the data added to the newly created file.
Code:
'Open the emplate file
Set wbTemplate = Workbooks.Open(strPath & "/" & strTemplate)
'Add the various bits of data
rngVRates.Copy
Range("FD_VehiclesStart").Offset(1, 0).PasteSpecial (xlPasteValues)
Range("FD_PassengerRate") = currPRate
Range("FD_Bf") = lngBF
Range("FD_Period") = strPeriod
Range("FD_PAYEEndDate") = dtYearEnd
Sheets("File Data").Visible = xlVeryHidden
Range("Claims_Name") = strName
Sheets("Claims").Protect Password:=strPassword
'Save as the new file in a different folder
wbTemplate.SaveAs strPath & "/Current/Mileage Claims " & strName & " " & strPeriod & ".xlsm"
'Close the 'saved' file
wbTemplate.Close savechanges:=False
TIA