Hi, what am i doing wrong. I am using this function to check and remove any nasty reference that aren't on the users pc.
Function CheckReference() As Boolean
Dim vbProj As VBProject ' This refers to your VBA project.
Dim chkRef As Reference ' A reference.
' Refer to the activedocument's VBA project.
Set vbProj = ActiveDocument.VBProject
' Check through the selected references in the References dialog box.
For Each chkRef In vbProj.References
' If the reference is broken, send the name to the Immediate Window.
If chkRef.IsBroken Then
Debug.Print chkRef.Name
vbProj.References.Remove chkRef
CheckReference = True
End If
Next
End Function
The point being, our pc's are almost same build but different IT departments will load certain objects whereas ours load different. BUT when it comes to debug, the system says Compile Error: User-defined type not defined.
Can anyone help?
Function CheckReference() As Boolean
Dim vbProj As VBProject ' This refers to your VBA project.
Dim chkRef As Reference ' A reference.
' Refer to the activedocument's VBA project.
Set vbProj = ActiveDocument.VBProject
' Check through the selected references in the References dialog box.
For Each chkRef In vbProj.References
' If the reference is broken, send the name to the Immediate Window.
If chkRef.IsBroken Then
Debug.Print chkRef.Name
vbProj.References.Remove chkRef
CheckReference = True
End If
Next
End Function
The point being, our pc's are almost same build but different IT departments will load certain objects whereas ours load different. BUT when it comes to debug, the system says Compile Error: User-defined type not defined.
Can anyone help?