Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 

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 10:13 PM.


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