Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-17-2016, 02:07 AM
misaak misaak is offline ADODB import of Excel data results in "Run-time error -2147467259: <sheet> is not a valid name." Windows 7 64bit ADODB import of Excel data results in "Run-time error -2147467259: <sheet> is not a valid name." Office 2013
Novice
ADODB import of Excel data results in "Run-time error -2147467259: <sheet> is not a valid name."
 
Join Date: Jun 2016
Posts: 3
misaak is on a distinguished road
Default ADODB import of Excel data results in "Run-time error -2147467259: <sheet> is not a valid name."

Hello,
<I apologize ahead of time if my description is too verbose :-)>

I have an Excel-based tool that has to regularly import data from 50+ user-selected, large CSV, XLS, and XLSX files into a single Excel workbook, and I am encountering a difficulty that would appear to be caused by Excel not releasing memory because performing multiple imports that replace the existing data will still eventually result in something as simple as launching a UserForm to fail with a message stating there is insufficient storage space.

I already have all of the various objects set to Nothing at the end of the various functions, and there are only three Boolean global variables in the code so I went searching online for ideas. One of the possible ideas was that the import of the XLS and XLSX files could be switched from using CopyFromRecordSet to using a SQL INSERT INTO command.

Unfortunately, my experience with SQL is almost nil, and my attempts to use the INSERT INTO encounters problems with unknown 'F#' field names (I think maybe caused by the imported worksheets having blanks for most of the first row columns) so I am trying to at least get SELECT * INTO to work to see if the memory issue might at least improve. Unfortunately, my attempts to implement the SELECT * INTO command result in the following error:

Run-time error '-2147467259 (80004005)':
'Temp$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.

NOTE: 'Temp' is just a sample name that I tried using, of which I have tried multiple. The exact message naturally reflects whatever worksheet name I have entered into the SQL string.When trying the SELECT * INTO, I made sure that there was not already a worksheet present with the name.

The code is run from the destination workbook into which the desired data needs to be copied from the closed source file(s); located in various directories on the same computer so no networking involved.

I am not allowed to post all of my code, but the below pieces comprise the core initial set related to the import attempt. The error occurs when attempting to execute the "rsCon.Execute szSQL" command.

Code:
Dim rsCon As Object 'the ADODB connection object
Dim szConnect As String  'the ADODB connection string
Dim szSQL As String  'the SQL query string
Dim FileArray() As String  'the full path and file name for each of the files to be imported
Dim FileSheet() As String  'contains the list of worksheet names to be imported already with a $ at the end
Dim i As Long  'a general loop counter
Dim j As Long  'a general loop counter
 
Set rsCon = CreateObject("ADODB.Connection")
szConnect = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & FileArray(i) & ";" & "Extended Properties=""Excel 8.0;HDR=No;IMEX=1;"""
rsCon.Open szConnect
szSQL = "SELECT * INTO [Temp$] IN '' [Excel 8.0;Database=" & ThisWorkbook.FullName & "] FROM [" & FileSheet(j) & "];"
rsCon.Execute szSQL
NOTES:
Example FileArray(i) could be "C:\Users\misaak\Desktop\TestData.xls"
Example FileSheet(j) could be "JON$"
Example ThisWorkbook.FullName could be "C:\Users\misaak\Desktop\TestCode.xlsm"

If a solution is identified for the JET engine import of the XLS files, then I hope to also apply it to the ACE engine import of the XLSX files (CSV files are imported using a FileSystemObject approach that splits the lines into the columns of a large array).

The version of Excel is the 32-bit 2013 version running in a 64-bit Windows 7. (The tool has to function using 32-bit since that is what the users have installed, and the tool has to remain solely in Excel.)

The current References that I have selected are the following, although I might not need all of them:
- Visual Basic for Applications
- Microsoft Excel 15.0 Object Library
- Microsoft ActiveX Data Objects 2.8 Library
- Microsoft Forms 2.0 Object Library
- Microsoft Windows Common Controls 6.0 (SP6)
- Microsoft Scripting Runtime
- OLE Automation

I have exhausted all of the ideas that I can think to try so I would greatly appreciate any ideas that someone might have. If you need any additional information, then please let me know.Thank you very much for any help that someone might provide.



Kind Regards,
Markus

Last edited by misaak; 06-17-2016 at 02:08 AM. Reason: Removing accidental [code] insert
Reply With Quote
  #2  
Old 06-17-2016, 02:48 AM
macropod's Avatar
macropod macropod is offline ADODB import of Excel data results in &quot;Run-time error -2147467259: &lt;sheet&gt; is not a valid name.&quot; Windows 7 64bit ADODB import of Excel data results in &quot;Run-time error -2147467259: &lt;sheet&gt; is not a valid name.&quot; Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted at: http://www.mrexcel.com/forum/excel-q...alid-name.html
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 06-18-2016, 07:29 AM
misaak misaak is offline ADODB import of Excel data results in &quot;Run-time error -2147467259: &lt;sheet&gt; is not a valid name.&quot; Windows 7 64bit ADODB import of Excel data results in &quot;Run-time error -2147467259: &lt;sheet&gt; is not a valid name.&quot; Office 2013
Novice
ADODB import of Excel data results in &quot;Run-time error -2147467259: &lt;sheet&gt; is not a valid name.&quot;
 
Join Date: Jun 2016
Posts: 3
misaak is on a distinguished road
Default

Thank you for the notice about the cross-posting etiquette and for adding the link for me
Reply With Quote
  #4  
Old 06-20-2016, 07:55 AM
misaak misaak is offline ADODB import of Excel data results in &quot;Run-time error -2147467259: &lt;sheet&gt; is not a valid name.&quot; Windows 7 64bit ADODB import of Excel data results in &quot;Run-time error -2147467259: &lt;sheet&gt; is not a valid name.&quot; Office 2013
Novice
ADODB import of Excel data results in &quot;Run-time error -2147467259: &lt;sheet&gt; is not a valid name.&quot;
 
Join Date: Jun 2016
Posts: 3
misaak is on a distinguished road
Default ADODB import of Excel data results in "Run-time error -2147467259: <sheet> is not a valid name."

Quote:
Originally Posted by macropod View Post

A discussion was held in the other aforementioned location, and the resultant information (provided by RoryA on Jun 20th, 2016) is as follows:

SELECT * INTO and INSERT INTO will only work when the destination workbook is closed whereas I am attempting to import data into an open workbook.

I am already importing the data using ADO CopyFromRecordSet command that works with an open destination workbook, but I keep randomly encountering problems with Excel appearing to either not release all of the memory after the code has finished or there is a memory leak somewhere because repeated executions of the code will cause Excel to eventually stop being able to even launch a simple UserForm stating that there insufficient storage to do so.

Since there are known memory leak issues with using ADO on open workbooks, I will have to consider what to do: change the approach of how the code and import should operate to maybe support using a closed intermediary workbook, open each source file and then obtain the data without using ADO, or live with the memory issue until everything gets ported over to something more capable of handling the massive amount of data.
Reply With Quote
Reply

Tags
adodb oledb import error, import data from excel, run-time -2147467259



Similar Threads
Thread Thread Starter Forum Replies Last Post
ADODB import of Excel data results in &quot;Run-time error -2147467259: &lt;sheet&gt; is not a valid name.&quot; Navigation Pane: Preselect "results" instead of "headings" DirkMcCallahan Word 1 03-24-2016 01:38 PM
ADODB import of Excel data results in &quot;Run-time error -2147467259: &lt;sheet&gt; is not a valid name.&quot; Error window: "Document name or path is not valid" SKE Word 1 01-28-2016 10:41 PM
Need help with conditional formatting & returning "Pass" / "Fail Results" in a Column N mikey386 Excel 2 12-11-2014 01:14 PM
Outlook "parameter values are not valid " ALJAMC Outlook 2 05-13-2014 08:22 AM
ADODB import of Excel data results in &quot;Run-time error -2147467259: &lt;sheet&gt; is not a valid name.&quot; Error Outlook 2003 " Receive much mail the same at the same time" nhat2nhat2 Outlook 1 09-26-2011 11:10 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft