2012-11-11 93 views
2

我有一个宏文件(.dotm文件),它不时被更改。使用Word VBA删除引用

但是,如果有人使用了来自不同文件的宏,它会为项目的References文件夹中的.dotm文件创建一个引用。我可以有一些脚本来检查该文件夹,并且如果该文件现在缺失/损坏以删除该引用?

回答

1

@ user1243498:下面的代码将删除更好的理解破引用

Sub referencecheck() 

Dim ref As Reference 

Dim yourproject As VBProject 

Set yourproject = ActiveDocument.VBProject 

For Each ref In yourproject.References 

If ref.IsBroken Then 

yourproject.References.Remove (ref) 

End If 

End Sub 

请参考以下网站

http://support.microsoft.com/kb/308340