K
KR
I have hundreds of end-user workbooks that all have the same module on our
network. I just found out that there is an error in the module, and I've
created an updated module that fixes the problem and I need to replace it in
all of the workbooks without messing with the data or settings of those
workbooks.I've exported a copy of the fixed module onto our network so my
code can pull it into each of the other workbooks.
Based on code from Chip Pearson's site, I've grabbed what seems to be the
key lines to add to my code that loops through and finds all of the affected
workbooks. However, I haven't any experience working with VBA at this level,
and I'm not sure which part to tweak to grab an exported module instead of
creating one from scratch.
From Chip's site:
'this part will hopefully remove the old version of the module
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents("ValidateAndPasteData")
ThisWorkbook.VBProject.VBComponents.Remove VBComp
'How do I modify this to import my ValidateAndPasteData.bas file?
Set VBComp = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_StdModule)
VBComp.Name = "NewModule"
'I'm thinking something like:
Set VBComp = ThisWorkbook.VBProject.VBComponents.Add(mypath &
"ValidateAndPasteData.bas")
'VBComp.Name = "NewModule"
but since this is a live environment and I don't have a good way to test
this before running it, I'm a little anxious to just do my usual
trial-and-error, because if the delete code works and the add code doesn't,
then I'll have broken all of the workbooks and angry coworkers...
Thanks for any help,
Keith
network. I just found out that there is an error in the module, and I've
created an updated module that fixes the problem and I need to replace it in
all of the workbooks without messing with the data or settings of those
workbooks.I've exported a copy of the fixed module onto our network so my
code can pull it into each of the other workbooks.
Based on code from Chip Pearson's site, I've grabbed what seems to be the
key lines to add to my code that loops through and finds all of the affected
workbooks. However, I haven't any experience working with VBA at this level,
and I'm not sure which part to tweak to grab an exported module instead of
creating one from scratch.
From Chip's site:
'this part will hopefully remove the old version of the module
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents("ValidateAndPasteData")
ThisWorkbook.VBProject.VBComponents.Remove VBComp
'How do I modify this to import my ValidateAndPasteData.bas file?
Set VBComp = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_StdModule)
VBComp.Name = "NewModule"
'I'm thinking something like:
Set VBComp = ThisWorkbook.VBProject.VBComponents.Add(mypath &
"ValidateAndPasteData.bas")
'VBComp.Name = "NewModule"
but since this is a live environment and I don't have a good way to test
this before running it, I'm a little anxious to just do my usual
trial-and-error, because if the delete code works and the add code doesn't,
then I'll have broken all of the workbooks and angry coworkers...
Thanks for any help,
Keith