|
-
Feb 27th, 2007, 03:53 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Referencing an Excel worksheet using ADO
I can do this sort of thing:
Select * FROM [Sheet1$]
but not if the worksheet is called 'Contracts & Licences'
What brackets etc would I need?
Renaming the worksheet would be a last resort because it is used by non-techies
Alternatively, is it possible to access a worksheet by an index value?
Thanks
Another light-hearted post from Guru 
-
Feb 27th, 2007, 03:58 AM
#2
Re: Referencing an Excel worksheet using ADO
Should be something like...
SELECT * FROM [Contracts & Licences$]
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 27th, 2007, 04:08 AM
#3
Re: Referencing an Excel worksheet using ADO
My post #13 in this thread shows how to open an ADO recordset object with the Excel workbook schema in order to retrieve the sheet names in the workbook. I have a few other examples throughout that thread but the OP was having some issues that may also be a bit confusing/redundant for your concerns.
Using an index position is not good as the user can add/delete sheets which could throw off the index positioning etc. If you retrieve the schema value of the sheet name then you will know exactly the name needed to reference that sheet in a second call to the sheet for selecting data from it.
http://www.vbforums.com/showthread.php?t=332610
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 27th, 2007, 04:42 AM
#4
Thread Starter
Addicted Member
Re: Referencing an Excel worksheet using ADO
Thanks! That was just the job, I needed single quotes around it
SELECT * FROM ['Contracts & Licences$']
Another light-hearted post from Guru 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|