-
I'm looking for someone who has done some extensive MS Word VBA code....
I have come across a problem that occurs when you attempt to save a word document that has a missing reference.
It reports an error "Disk is Full".
I have worked that bit out and I have even managed to locate which of the references is missing using the :
Code:
ActiveDocument.VBProject.References(x).IsBroken
But what I need to do now is use VBA to actually REMOVE that missing reference. I know the function that I require, it is :
Code:
ActiveDocument.VBProject.References.Remove(<Reference>)
The problem is that the parameter <Reference> isn't just the item number of the reference I want to remove, the help files say that it is the "reference object" itself.
Now I have tried evertything from :
Code:
ActiveDocument.VBProject.References.Remove(3)
to
ActiveDocument.VBProject.References.Remove(ActiveDocument.VBProject.References(3))
But it keeps giving me errors.
If anyone has any idea what the EXACT syntax is for this command could they please give me a hand... it would be muchly appreciated.
-
You have to pass an object as a paramater. So you can try something like this:
Code:
Dim objRef As Object
Dim i As Integer
For i = 1 To ActiveDocument.VBProject.References.Count
Set objRef = ActiveDocument.VBProject.References(i)
Debug.Print objRef.Name
If objRef.IsBroken Then
ActiveDocument.VBProject.References.Remove objRef
End If
Next
Good luck,