473,770 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Workbook s.Open("C:\File name.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.Applicati on
Dim objWorkBook As Excel.Workbook
objExcel = CType(CreateObj ect("Excel.Appl ication"),
Excel.Applicati on)
Dim objOldCI As System.Globaliz ation.CultureIn fo =
System.Threadin g.Thread.Curren tThread.Current Culture
System.Threadin g.Thread.Curren tThread.Current Culture = New
System.Globaliz ation.CultureIn fo("en-US")
fail==> objWorkBook = objExcel.Workbo oks.Open(strFil eName)
System.Threadin g.Thread.Curren tThread.Current Culture = objOldCI

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

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

Maybe instead of using createobject
objExcel = New Excel.Applicati on 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.Workboo ks.Open("C:\Fil ename.xls")'
it pops up an error msg -- 'object reference not set to an instance of anobject'

Source code as folllow

Dim objExcel As Excel.Applicati on
Dim objWorkBook As Excel.Workbook
objExcel = CType(CreateObj ect ("Excel.Applica tion"),Excel.Applicat ion)
Dim objOldCI As System.Globaliz ation.CultureIn fo =System.Threadi ng.Thread.Curre ntThread.Curren tCulture
System.Threadin g.Thread.Curren tThread.Current Culture = NewSystem.Globali zation.CultureI nfo("en-US")
fail==> objWorkBook = objExcel.Workbo oks.Open (strFileName) System.Threadin g.Thread.Curren tThread.Current Culture =
objOldCI
Does anyone know the solution??.... please guide me into the rightdirection...Th anks

cheers,
Ivan
.

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

"Jorge" <an*******@disc ussions.microso ft.com> ???
news:1d******** *************** ******@phx.gbl ???...
Hi

Maybe instead of using createobject
objExcel = New Excel.Applicati on 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.Workboo ks.Open("C:\Fil ename.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.Applicati on
Dim objWorkBook As Excel.Workbook
objExcel = CType(CreateObj ect

("Excel.Applica tion"),
Excel.Applicat ion)
Dim objOldCI As

System.Globaliz ation.CultureIn fo =
System.Threadi ng.Thread.Curre ntThread.Curren tCulture

System.Threadin g.Thread.Curren tThread.Current Culture = New
System.Globali zation.CultureI nfo("en-US")
fail==> objWorkBook = objExcel.Workbo oks.Open

(strFileName)

System.Threadin g.Thread.Curren tThread.Current Culture =
objOldCI

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

the right
direction...Th anks

cheers,
Ivan
.

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

objExlSheet = objWorkBookOpen (strFileName)

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

Maybe instead of using createobject
objExcel = New Excel.Applicati on 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.Workboo ks.Open("C:\Fil ename.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.Applicati on
> Dim objWorkBook As Excel.Workbook
> objExcel = CType(CreateObj ect

("Excel.Applica tion"),
>Excel.Applicat ion)
> Dim objOldCI As

System.Globaliz ation.CultureIn fo =
>System.Threadi ng.Thread.Curre ntThread.Curren tCulture
>

System.Threadin g.Thread.Curren tThread.Current Culture = New >System.Globali zation.CultureI nfo("en-US")
>fail==> objWorkBook = objExcel.Workbo oks.Open

(strFileName)
>

System.Threadin g.Thread.Curren tThread.Current Culture =
objOldCI
>
>Does anyone know the solution??.... please guide me

into the right
>direction...Th anks
>
>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*******@disc ussions.microso ft.com> ???
news:1d******** *************** ******@phx.gbl ???...
Got it before your try to open the file you need to
objWorkBook = objExcel.Workbo oks

objExlSheet = objWorkBookOpen (strFileName)

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

working .....

"Jorge" <an*******@disc ussions.microso ft.com> ???
news:1d******* *************** *******@phx.gbl ???...
Hi

Maybe instead of using createobject
objExcel = New Excel.Applicati on 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.Workboo ks.Open("C:\Fil ename.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.Applicati on
> Dim objWorkBook As Excel.Workbook
> objExcel = CType(CreateObj ect
("Excel.Applica tion"),
>Excel.Applicat ion)
> Dim objOldCI As
System.Globaliz ation.CultureIn fo =
>System.Threadi ng.Thread.Curre ntThread.Curren tCulture
>
System.Threadin g.Thread.Curren tThread.Current Culture = New >System.Globali zation.CultureI nfo("en-US")
>fail==> objWorkBook = objExcel.Workbo oks.Open
(strFileName)
>
System.Threadin g.Thread.Curren tThread.Current Culture =
objOldCI
>
>Does anyone know the solution??.... please guide me into the right
>direction...Th anks
>
>cheers,
>Ivan
>
>
>.
>

.

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1806
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 already automated most of the formatting task of the raw data, and I am wondering if it is possible to automate the original importation too (like when I click on FILE>Import). Anyone have an idea?
1
2124
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) if that particular Excel is alreay launch, get the Excel Object 3) run a macro on the Excel Object I made some progress using
2
4367
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
1890
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 pulled from an old UNIX based system, then converted to Excel. I want the user to be able to use the web app to select and upload the file to the server, then press a button to have the SQL server process the Excel file and import it. I know I can do...
15
11142
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 ( update.zip ), and can automate the FTP'ing of the SE zip file to the update site. I have, as yet, been unable to find a way of automating the creation of a SE zip file from the initial update.zip. I have performed a rather
3
4904
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 cannot find a way to trigger a button click event from Excel for an Access form. To be more precise, I have Access db called a.mdb. a.mdb has a.form and a.command button inside the form I have xls sheet called b.xls. How I will fire an onclick event...
2
1508
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 in .NET? -- Alexander L. Wykel AW Software Works
0
3478
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 obtain data in a range using arrays" (URL: http://support.microsoft.com/kb/308407), and I run into same problem as described in the MSDN Forums "Newbie Q regarding MFC automation client app"...
8
5350
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 excel I get the error Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005. System.UnauthorizedAccessException: Retrieving the COM class factory for
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10259
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.