MBlackburn
MBlackburn

Reputation: 117

Remove Reference using Word VBA

I have a macro file (.dotm file) which gets changed from time to time.

However, if someone used a macro from a different file, it creates a reference to the .dotm file in the References folder for the project. Can I have some script that checks that folder and if that file is now missing/broken to remove that Reference?

Upvotes: 2

Views: 1888

Answers (1)

Matchendran
Matchendran

Reputation: 433

@user1243498 : Following code will remove the broken references

 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

for better understanding please refer the following site

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

Upvotes: 1

Related Questions