473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1831
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John Marble | last post by:
I have around 400 excel files filled with data that I need to import in ACCESS. The tricky part is that they must be imported one at time, and properly corrected before importing the next one. I...
1
by: Michael Wu | last post by:
I wonder if anyone can shed some light on how to automate Excel from a C# program. What I like to do is this, 1) Find if an Excel spreadsheet is alreay opened (identify the Excel file path) 2)...
2
by: jcm | last post by:
I am trying to Automate Office with C#. How can I freeze panes in excel with Microsoft Visual C#? I hope someone can help me with this. Please help !
11
by: David Lozzi | last post by:
Hello, I need to automate importation of a excel file into a table. Here's my scenario: I'm writing an ASP.NET application where users can pull reports on imported data. The imported data is...
15
by: Karl | last post by:
Hi all, I regularly use FTP to place Self Extracting Zip files on the web for remote users to update their datafiles. Works very nicely. I have automated the creation of the initial zip file (...
3
by: aniphilip | last post by:
Hi All, I have a requirement to automate Access functionality from Excel. I need to open Access, trigger button events and close Access from Excel. I Achieved opening Access from Excel. I...
2
by: =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?= | last post by:
Is it possible to automate a COM object ebmeded in an excel document run the process and return the results in a C# .NET application? Or better yet extract the com object some how and just run it...
0
by: ishay44 | last post by:
Hello! I try to build (using Visual 2005 and Excel 2007) the example described in the Microsoft Help and Support "How to automate Excel from MFC and Visual C++ 2005 or Visual C++ .NET to fill or...
8
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a web site that automates excel. This site runs in server 2003. iis 6.0 office 2003 installed I moved this app to server 2008 iis 7.0 office 2003 installed Now when I try to automate...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.