Remove missing reference programmatically

  • Thread starter Thread starter Nacho Nachev
  • Start date Start date
N

Nacho Nachev

Hello,

I am accessing Excel object from a C# plugin. Sometimes in my target
documents there are missing Compoment references, which I should remove.

I use the following fragment of code to do this:
 
Hello,

I am accessing Excel object from a C# plugin. Sometimes in my target
documents there are missing Compoment references, which I should remove.

Sorry, I sent it incomplete mistakenly. Here's the whole message.
---

I use the following fragment of code to do this:


for (int j = 1; j <= wbk.VBProject.References.Count; j++)
{
VBIDE.Reference myref = wbk.VBProject.References.Item(j);

if (myref.IsBroken == true)
{
wbk.VBProject.References.Remove(myref);
}
}

The problem is that I get the following exception: for (int j = 1; j <=
wbk.VBProject.References.Count; j++)
{
VBIDE.Reference myref = wbk.VBProject.References.Item(j);

if (myref.IsBroken == true)
{
wbk.VBProject.References.Remove(myref);
}
}

The problem is that I get the following exception: "Object library not
registered". But the reference is still there and I cannot add fresh
reference to the project "Name conflicts with existing module, project, or
object library".

Do you have any suggestion how I get out of this mess and remove the missing
reference successfully?

Thank you for your time,
Nacho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top