469,927 Members | 1,649 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Bugs?? problem automate excel in VB.net .. please help~

Hi All,

I have tried to automate excel in vb.net
and i found a problem that i can't find the solution in anywhere...
i hope someone can help me in this group....

the problem is i try using the excel function --
'Excel.Workbooks.Open("C:\Filename.xls")'
it pops up an error msg -- 'object reference not set to an instance of an
object'

Source code as folllow

Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
objExcel = CType(CreateObject("Excel.Application"),
Excel.Application)
Dim objOldCI As System.Globalization.CultureInfo =
System.Threading.Thread.CurrentThread.CurrentCultu re
System.Threading.Thread.CurrentThread.CurrentCultu re = New
System.Globalization.CultureInfo("en-US")
fail==> objWorkBook = objExcel.Workbooks.Open(strFileName)
System.Threading.Thread.CurrentThread.CurrentCultu re = objOldCI

Does anyone know the solution??.... please guide me into the right
direction...Thanks

cheers,
Ivan
Nov 20 '05 #1
4 1700
Hi

Maybe instead of using createobject
objExcel = New Excel.Application might work...

Kind Regards
Jorge
-----Original Message-----
Hi All,

I have tried to automate excel in vb.net
and i found a problem that i can't find the solution in anywhere...i hope someone can help me in this group....

the problem is i try using the excel function --
'Excel.Workbooks.Open("C:\Filename.xls")'
it pops up an error msg -- 'object reference not set to an instance of anobject'

Source code as folllow

Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
objExcel = CType(CreateObject ("Excel.Application"),Excel.Application)
Dim objOldCI As System.Globalization.CultureInfo =System.Threading.Thread.CurrentThread.CurrentCult ure
System.Threading.Thread.CurrentThread.CurrentCultu re = NewSystem.Globalization.CultureInfo("en-US")
fail==> objWorkBook = objExcel.Workbooks.Open (strFileName) System.Threading.Thread.CurrentThread.CurrentCultu re =
objOldCI
Does anyone know the solution??.... please guide me into the rightdirection...Thanks

cheers,
Ivan
.

Nov 20 '05 #2
Thanks for your reply... but i've tried it and still not working .....

"Jorge" <an*******@discussions.microsoft.com> ???
news:1d*****************************@phx.gbl ???...
Hi

Maybe instead of using createobject
objExcel = New Excel.Application might work...

Kind Regards
Jorge
-----Original Message-----
Hi All,

I have tried to automate excel in vb.net
and i found a problem that i can't find the solution in

anywhere...
i hope someone can help me in this group....

the problem is i try using the excel function --
'Excel.Workbooks.Open("C:\Filename.xls")'
it pops up an error msg -- 'object reference not set to

an instance of an
object'

Source code as folllow

Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
objExcel = CType(CreateObject

("Excel.Application"),
Excel.Application)
Dim objOldCI As

System.Globalization.CultureInfo =
System.Threading.Thread.CurrentThread.CurrentCult ure

System.Threading.Thread.CurrentThread.CurrentCultu re = New
System.Globalization.CultureInfo("en-US")
fail==> objWorkBook = objExcel.Workbooks.Open

(strFileName)

System.Threading.Thread.CurrentThread.CurrentCultu re =
objOldCI

Does anyone know the solution??.... please guide me into

the right
direction...Thanks

cheers,
Ivan
.

Nov 20 '05 #3
Got it before your try to open the file you need to
objWorkBook = objExcel.Workbooks

objExlSheet = objWorkBookOpen(strFileName)

Kind Regards
Jorge
-----Original Message-----
Thanks for your reply... but i've tried it and still not working .....
"Jorge" <an*******@discussions.microsoft.com> ???
news:1d*****************************@phx.gbl ???...
Hi

Maybe instead of using createobject
objExcel = New Excel.Application might work...

Kind Regards
Jorge
>-----Original Message-----
>Hi All,
>
>I have tried to automate excel in vb.net
>and i found a problem that i can't find the solution in
anywhere...
>i hope someone can help me in this group....
>
>the problem is i try using the excel function --
>'Excel.Workbooks.Open("C:\Filename.xls")'
>it pops up an error msg -- 'object reference not set
to an instance of an
>object'
>
>Source code as folllow
>
> Dim objExcel As Excel.Application
> Dim objWorkBook As Excel.Workbook
> objExcel = CType(CreateObject

("Excel.Application"),
>Excel.Application)
> Dim objOldCI As

System.Globalization.CultureInfo =
>System.Threading.Thread.CurrentThread.CurrentCult ure
>

System.Threading.Thread.CurrentThread.CurrentCultu re = New >System.Globalization.CultureInfo("en-US")
>fail==> objWorkBook = objExcel.Workbooks.Open

(strFileName)
>

System.Threading.Thread.CurrentThread.CurrentCultu re =
objOldCI
>
>Does anyone know the solution??.... please guide me

into the right
>direction...Thanks
>
>cheers,
>Ivan
>
>
>.
>

.

Nov 20 '05 #4
Sorry guys, I'm fool...
I forgot to emphasis the error only exist in Win98 machine

it works just fine in WinXP & Win2K

and one more thing Jorge...
I have tried your code before and it's not working in Win98 as well... (but
once again work fine in WinXP & Win2K)
"Jorge" <an*******@discussions.microsoft.com> ???
news:1d*****************************@phx.gbl ???...
Got it before your try to open the file you need to
objWorkBook = objExcel.Workbooks

objExlSheet = objWorkBookOpen(strFileName)

Kind Regards
Jorge
-----Original Message-----
Thanks for your reply... but i've tried it and still not

working .....

"Jorge" <an*******@discussions.microsoft.com> ???
news:1d*****************************@phx.gbl ???...
Hi

Maybe instead of using createobject
objExcel = New Excel.Application might work...

Kind Regards
Jorge
>-----Original Message-----
>Hi All,
>
>I have tried to automate excel in vb.net
>and i found a problem that i can't find the solution in anywhere...
>i hope someone can help me in this group....
>
>the problem is i try using the excel function --
>'Excel.Workbooks.Open("C:\Filename.xls")'
>it pops up an error msg -- 'object reference not set to an instance of an
>object'
>
>Source code as folllow
>
> Dim objExcel As Excel.Application
> Dim objWorkBook As Excel.Workbook
> objExcel = CType(CreateObject
("Excel.Application"),
>Excel.Application)
> Dim objOldCI As
System.Globalization.CultureInfo =
>System.Threading.Thread.CurrentThread.CurrentCult ure
>
System.Threading.Thread.CurrentThread.CurrentCultu re = New >System.Globalization.CultureInfo("en-US")
>fail==> objWorkBook = objExcel.Workbooks.Open
(strFileName)
>
System.Threading.Thread.CurrentThread.CurrentCultu re =
objOldCI
>
>Does anyone know the solution??.... please guide me into the right
>direction...Thanks
>
>cheers,
>Ivan
>
>
>.
>

.

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Michael Wu | last post: by
2 posts views Thread by jcm | last post: by
11 posts views Thread by David Lozzi | last post: by
2 posts views Thread by =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?= | last post: by
8 posts views Thread by =?Utf-8?B?SmVycnkgQw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.