Link to home
Start Free TrialLog in
Avatar of orgrau9
orgrau9Flag for Afghanistan

asked on

Cannot set VBA object in windows 7

Hello X-perts,

I have a VB.NET application that is registered as a COM for Excel. In the VBA code it is loaded from Excel as:
   
Public Screening As Qmf.MainForm

Open in new window

-------------
  activation in the sub:
    Set Screening = New Qmf.MainForm
    Call Screening.start(ThisWorkbook.Name, vendorType, locHFI, locQuant, lastS)

Open in new window

The line
Set Screening = New Qmf.MainForm

Open in new window

throws an automation error in Excel VBA with code "One or more arguments are invalid."

Now read the most important part:

1) This is a mature application that works on many PCs with different OS (XP, Win 7, Vista) for years. It works perfectly fine on my other Win 7 64 machine.

2) The problem started when I installed it to a brand new Lenovo laptop with Windows 7. It is the problem with only one particular PC.

3) I tried many things to isolate that error including:
     a) Different versions of MS Office - 2007 and 2010.
     b) Installing the same .NET libraries as on other machines  
     c) Installing Visual Studio
     d) replacing the factory HDD with Win 7 by other HDD from a different PC (also Win 7 64). Obviously, all the drivers were messed up, but the application itself worked perfectly.

4) The COM library is registered without errors, visible in Excel references and there are no compilation errors.

I am out of ideas what to try....

Please help.
Avatar of aikimark
aikimark
Flag of United States of America image

What happens if you declare the variable like this?
Public Screening As New Qmf.MainForm

Open in new window

Are you registering using the Greatest Version of RegAsm.exe?  If 4.0 is installed and you register using the 2.0 RegAsm things don't work correctly even when the application is built on the 2.0 framework, it has been a long time so I don't remember the specific issues that arrise.

I think it is a little weird that the error sites invalid arguments to a method that doesn't have arguments which seems to point to a problem with the code that runs during the new call.  Have you tried attaching the debugger?
Avatar of orgrau9

ASKER

It is registered by Install shield as COM dll - there are two libs: dll and tlb.

The problem is related to some missing dependencies for one of the dll, inside that application. I transfer the whole development environment to that "bad PC" to test. When trying to build a solution, it gives an error - "cannot register assembly -- could not load file -- one or more arguments are invalid".

The whole problem is because of some missing assemblies in the pool.
SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of orgrau9

ASKER

Thank you, Corey2. I will try FuselogVW and get back with the results.