ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem in making Excel.WorkBook from VB.NET (https://www.excelbanter.com/excel-programming/350743-problem-making-excel-workbook-vbulletin-net.html)

Wael_Bakr

Problem in making Excel.WorkBook from VB.NET
 
I made an application in Vb.NET that loads an excel application and then
start to generate some reports on it, my problem is:

1 - the application was running with no problems and after formatting my PC,
installing Windows XP, SP2, Office 2003 + SP1, Visual studio 2003 and start
running the program it succeeded in making an excel application object, but
it faild to create a workbook or any other feature or property, except
"ExcelApp.Visible=True".

2 - when I start to debug the code, it gives me the following error " Old
format or Invalid Type Library"

3 - I checked my refrences and found that there is no problem, the
application compiles with no errors.

4 - I made my refrences by adding a refrence to excel.exe file into my
project and it adds automatically "Microsoft.Office.Core" refrence and
"VBIDE" refrence to my project.

I have tried to format my PC again and install office again and test, but it
still gives me the same error.

I have tested it on another PCs(3 different PCs) and it worked fine and
correctly with no problem

what does this error message mean?
What is its cause?
is there anything that I did not take care of after format?
what should I do in order to avoid this error message?


here is the code snippit that makes the problem:

Dim ExcelApp As Excel.Application
ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = True

Dim WB As Excel.Workbook
WB = ExcelApp.Workbooks.Add ' <==== Here Where it Crashs and give me
the error message " Old format or Invalid Type Library"




NickHK

Problem in making Excel.WorkBook from VB.NET
 
Wael_Bakr,
This VB.Net code ?
Look a lot like VB6 to me. Does Vb.Net use all that Interop stuff ?

NickHK


"Wael_Bakr" wrote in message
...
I made an application in Vb.NET that loads an excel application and then
start to generate some reports on it, my problem is:

1 - the application was running with no problems and after formatting my

PC,
installing Windows XP, SP2, Office 2003 + SP1, Visual studio 2003 and

start
running the program it succeeded in making an excel application object,

but
it faild to create a workbook or any other feature or property, except
"ExcelApp.Visible=True".

2 - when I start to debug the code, it gives me the following error " Old
format or Invalid Type Library"

3 - I checked my refrences and found that there is no problem, the
application compiles with no errors.

4 - I made my refrences by adding a refrence to excel.exe file into my
project and it adds automatically "Microsoft.Office.Core" refrence and
"VBIDE" refrence to my project.

I have tried to format my PC again and install office again and test, but

it
still gives me the same error.

I have tested it on another PCs(3 different PCs) and it worked fine and
correctly with no problem

what does this error message mean?
What is its cause?
is there anything that I did not take care of after format?
what should I do in order to avoid this error message?


here is the code snippit that makes the problem:

Dim ExcelApp As Excel.Application
ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = True

Dim WB As Excel.Workbook
WB = ExcelApp.Workbooks.Add ' <==== Here Where it Crashs and give

me
the error message " Old format or Invalid Type Library"






tony h[_16_]

Problem in making Excel.WorkBook from VB.NET
 

I was feeling quite confident about the answer until you said it worked
on other pcs.

I am not sure why you need a reference to the IDE but you may do, what
you haven't mentioned is a reference to the excel object reference
library.

You do need to make sure that you pick up compatible sets of libraries
otherwise you will be trying to operate on an object with two different
versions of EXCEL. Which what I suspect your error is indicating.

Hope this helps


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=502392



All times are GMT +1. The time now is 09:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com