Rather than 'updating' workbooks, make your code into an add-in. Now,
all you have to do is replace the add-in with the new version.
--
Regards,
Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
In article ,
says...
We are trying to push some new code to the our code modules in a workbook.
The issue we face right now is that the modules are protected. Is there a
way to programmatically remove the module protection. So that I can run the
bellow code so that I do not get an error accessing the protected modules.
Sub PatchWorkbook(PatchWBPath As String)
Dim ve As VBE
Dim xl As Excel.Application
Dim wb As Workbook
Dim codeModule As codeModule
Set xl = New Excel.Application
xl.EnableEvents = False
xl.DisplayAlerts = False
Set wb = xl.Workbooks.Open(PatchWBPath, False, False, , "", "", , , , ,
False)
wb.UpdateRemoteReferences = False
xl.Calculation = xlCalculationManual
Set ve = xl.VBE
Debug.Print ve.VBProjects(1).Protection
Set codeModule = ve.ActiveVBProject.VBComponents("ThisWorkbook")
wb.Save
wb.Close
Set wb = Nothing
Set xl = Nothing
End Sub
Thanks in advance!
Reg,
Adam