VbComponents.Remove doesn't always remove module

后端 未结 8 878
我寻月下人不归
我寻月下人不归 2021-01-02 01:01

I\'m trying to use Chip Pearson\'s code for overwriting an existing VBA code module with an import from another project. Original code here.

The particular section

8条回答
  •  悲&欢浪女
    2021-01-02 01:21

    I tried the renaming and found that it caused problems with the sheet modules and ThisWorkbook. So I modified it slightly to rename only the non document modules. This seems to work cleanly.

            If .Item(ModuleName).Type <> vbext_ct_Document Then
                .Item(ModuleName).Name = ModuleName & "_OLD"
                .Remove .Item(ModuleName & "_OLD")
            Else
                .Remove .Item(ModuleName)
            End If
    

提交回复
热议问题