Checking and removing broken references

sam slade

New Member
Joined
Sep 14, 2006
Messages
22
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?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,884
Hi sam slade

Maybe you just need to add the reference to the object library that manipulates objects in vba, visual basic 6, etc.

In the vb editor:

Tools>References

Look for:

Microsoft Basic for Applications Extensibility 5.3

Enable it.

Hope this helps
PGC
 

sam slade

New Member
Joined
Sep 14, 2006
Messages
22
hi pgc,

adding the reference has worked for my pc, except no the system is saying that Programmic access to Visual Basic project is not trusted. :devilish:

Is this becuase i locked the project with a password?
 

sam slade

New Member
Joined
Sep 14, 2006
Messages
22
nope not the password,

i think i solved this by selecting trust access to VB project in the Trusted Publishers tab of the security form.

thanks pgc for your help.
 

sam slade

New Member
Joined
Sep 14, 2006
Messages
22
lol,

thanks pgc, i still followed your link and was freaked by 'glaswegian's signature detailing my ISP and IP address ... with a strange quote .. or is it just me? love it!!
 

sam slade

New Member
Joined
Sep 14, 2006
Messages
22
HA!!!

don't freak me out dude!!

uh oh, boss is coming!!!

cell A2 = SOMEFORMULA(A5:A26) + SOMEMORET(2sugars)
 

Forum statistics

Threads
1,141,587
Messages
5,707,247
Members
421,498
Latest member
matinebi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top