473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help: Importing from unsaved Excel file. Cannot find the activesheet.

1 New Member
I can import data from Excel using the following code if the spreadsheet is saved on the computer and has a non-empty path name:

string connStr = "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" + oXL.ActiveWorkb ook.Path + "\\" + oXL.ActiveWorkb ook.Name + ";" + "Extended Properties=Exce l 8.0";

OleDbCommand cmdSelect = new OleDbCommand("S ELECT * FROM [" + oSheet.Name + "$]", conn);

However, if the running instance of Excel is not saved on the computer and has an empty path name, I need to change the connection line to:

connStr = "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" + oXL.ActiveWorkb ook.Name + ".xls;" + "Extended Properties=Exce l 8.0";

After, when I try to execute the command, I get an error:

"The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and path name correctly."

My guess, it cannot find Sheet1 of the current instance of Excel because there is no path name. Any thoughts?
Feb 11 '08 #1
0 1122

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3750
by: c duden | last post by:
Excel won't allow documents to be linked to a worksheet in office 2000 when using C# to create an add-in. The following code snippets are what was used in the attempts (there are more permutations of parameters, but for brevity...): // one - based on code from Matt Reynolds' website Excel.Worksheet active =...
1
9316
by: v_verno | last post by:
Good day, I have a web page that shows info retrieved from a MySQL db and I would like to convert all these data into an .XLS file. Have searched the net high and low but seems that I'm unable to find a free tool that can do the above and therefore I'm forced to do everything from scratch. Till now have developed two different versions of...
14
5763
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the SQL DATABASE, probably by the click of a button. Is this possible? & what is the BEST APPROACH for doing this? & also if any links are there do...
3
7976
by: austin1539 | last post by:
I am trying to run an Access query from Excel. The query, called "ProdActs1" works in Access and is run from using information from a table called "Queries". When a button is clicked in Excel, data currently in the table is deleted and new data is sent based on cell value on the Excel worksheet. So far, I can delete the old records and add new...
2
3435
by: rajini | last post by:
Hai.... i have Vc++ code . i need to create Dll file by using following code can u help me....here with this i had sent my vc++ code VARIANT root = {0}; // Generic IDispatchs VARIANT parm = {0}; // Generic Parameters VARIANT rVal = {0}; // Temporary result holder
3
4878
by: Chris | last post by:
I have a python script that is driving Excel and using the win32com module. However, upon program completion there's still an Excel.exe process running in the background that I must terminate through Task Manager. Reading up on other threads indicate that maybe I still have some Excel objects referenced within my code. Is this why the process...
0
2006
by: nphankey | last post by:
I'm struggling to tame Excel using Python and COM. Most of the following code is working except for the setting of the activesheet. Also, I would like to know how to release a COM object without closing the application / dispatcher that launched excel? class ExcelCom32(object): """ Access Excel using python via COM.
0
2987
by: JFKJr | last post by:
I have an excel file, which has columns C and D grouped together, I am trying to delete blank columns and rows from the excel file, ungroup the columns and import the file to MS Access using Access VBA code. The following is the Access VBA code I used to delete blank columns and rows in the excel file. But, unfortunately, the resultant excel...
0
7693
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...
0
7605
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...
0
7917
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. ...
0
8118
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...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
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...
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.