S
Sam Johnson
I have an excel document that is self-updating (or will be). When the
On_Open event fires, it compares the version of it's code, with that of a
master document. If it needs to update, it is supposed to remove all of it's
non-document modules, then copy over all the non-document modules from the
master document. Sometimes, the deletion routine fails to delete all the
modules (it will leave a windows form, and one code module. I'd appreciate
any suggestions on how to improve it. Is there a way to verify that the
remove command was executed succesfully?
Here's the code:
'remove every non-worksheet object from current doc
For Each VBComp In CurrentWB.VBProject.VBComponents
If (CompTypeToName(VBComp) <> "Document") Then
DeleteVBComponent CurrentWB, VBComp
End If
Next VBComp
'Copy every non-worksheet object from source doc, to current
doc.
For Each VBComp In SourceWB.VBProject.VBComponents
If (CompTypeToName(VBComp) <> "Document") Then
Call CopyModule(SourceWB, VBComp.Name, CurrentWB)
End If
Next VBComp
On_Open event fires, it compares the version of it's code, with that of a
master document. If it needs to update, it is supposed to remove all of it's
non-document modules, then copy over all the non-document modules from the
master document. Sometimes, the deletion routine fails to delete all the
modules (it will leave a windows form, and one code module. I'd appreciate
any suggestions on how to improve it. Is there a way to verify that the
remove command was executed succesfully?
Here's the code:
'remove every non-worksheet object from current doc
For Each VBComp In CurrentWB.VBProject.VBComponents
If (CompTypeToName(VBComp) <> "Document") Then
DeleteVBComponent CurrentWB, VBComp
End If
Next VBComp
'Copy every non-worksheet object from source doc, to current
doc.
For Each VBComp In SourceWB.VBProject.VBComponents
If (CompTypeToName(VBComp) <> "Document") Then
Call CopyModule(SourceWB, VBComp.Name, CurrentWB)
End If
Next VBComp