I hm begginerin VBA. I want to remove the broken reference from word documents. I can able to find out number of reference in document including broken reference. but when i try to remove the reference/ get the broken reference name with the following code, I got run time error. I tried with following codes but nothing worked out for me.

Code as follows:

Dim vbProj As VBProject
Dim chkRef As Reference
Dim i as Integer

I= VBE.ActiveVBProject.references.Count
Msgbox i
Set vbProj = ActiveDocument.VBProject

For Each chkRef In vbProj.References
Msgbox chkref.Name
If chkRef.IsBroken Then
vbProj.References.Remove chkRef

End If


End Sub

Sub A()

Dim Z as object
For Each z In Application.VBE.ActiveVBProject.references

If z.IsBroken = true Then
Set Z = Application.VBE.ActiveVBProject.references.item("P PC")
Application.VBE.ActiveVBProject.references.Remove z

End If


End sub

Whenever the code reaches the broken reference , I got the runtime error (Name, FullPath doent work ). Machine is window s7 64 bit.. word is 32 bit version 2010.

Thanks in advance..