SharePoint and saving file via VBA

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,632
Office Version
  1. 365
Platform
  1. Windows
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.
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
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
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top