VbComponents.Remove doesn't always remove module

后端 未结 8 816
我寻月下人不归
我寻月下人不归 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:11

    I had the same issue with PowerPoint, but I guess the solution could apply to any Microsoft Office application implementing VBA.

    I stopped having issues after I did Remove in a separate procedure:

    Public Sub RemoveVBComponent(ioVBComponents As VBComponents, ioVBComponent As VBComponent)
        Call ioVBComponents.Remove(ioVBComponent)
    End Sub
    

    that I called this way:

    With ToVBProject
        Call RemoveVBComponent(.VBComponents,.VBComponents.Item(ModuleName))
    End With
    

提交回复
热议问题