ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Update workbooks from a master (https://www.excelbanter.com/excel-programming/335343-update-workbooks-master.html)

blue102040

Update workbooks from a master
 

I have the code below to update workbooks from a master, thanks to Leit
Ross.

I want to change the code so it uses the original file name rather tha
add the Temp files. I have tried changing the WkbName to the same a
the existing workbooks but the workbooks are write reserved, when I ru
the code on these workbooks I get the message Error number = 1004
operation failed workbook is write reserved. I do know the password t
open the workbooks to enable write access so can add this to the code
if required.

Previous thread
http://www.excelforum.com/showthread...highlight=blue

Thanks Blue



Public Sub UpdateWorkbooks()

Dim Ret
Dim I As Integer
Dim W As Integer
Dim InputMsg As String
Dim WeekStr As String
Dim WkbName As String

On Error GoTo Fault

'Ask for the Week Number
InputMsg = "Enter the Week Number to start with below." & vbCrLf _
&"To Exit this Macro, Click Cancel or leave the entry below blank an
Click OK."

WeekStr = InputBox(InputMsg, "Update Workbooks")

If WeekStr = "" Then Exit Sub

W = Val(WeekStr)

'Update Workbooks Loop
For I = W to 52

'Save this Workbook as the New Workbook - Asks to Replace the File
WkbName = ThisWorkbook.Path & "\TEMP WK" & I & ".xls"
ThisWorkbook.SaveAs Filename:= WkbName, FileFormat:= xlWorkbookNormal

Next I

Fault:
Msg = "An Error has occurred. This macro will now Terminate." & vbCrL
_
& "Error Number = " & Err.Number & vbCrLf _
& "Message: " & Err.Description

Ret = MsgBox(Msg, vbOkonly + vbCritical, "Update Workbooks Macro")
Err = 0

End Su

--
blue10204
-----------------------------------------------------------------------
blue102040's Profile: http://www.excelforum.com/member.php...fo&userid=2552
View this thread: http://www.excelforum.com/showthread.php?threadid=38964



All times are GMT +1. The time now is 11:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com