|
-
Oct 9th, 2005, 03:08 AM
#1
Thread Starter
PowerPoster
Mschart and Excel
Is it possible to use ADO in Excel to return a recordset?
I've got about 1000 rows for my data that will be plotted on a MSChart but I don't want to loop from row 1 to row 1000 to get all the values.
Can I use something like....
VB Code:
SELECT * FROM WorkSheetName Range A1 to A1000
Last edited by lintz; Oct 10th, 2005 at 01:06 AM.
-
Oct 9th, 2005, 12:13 PM
#2
Re: Mschart and Excel
Yes, but you need to add the reference to ADO in the VBA IDE. Then its about the same as it is from outside of Excel. Then when you have your recordset you can show it on your chart/form.
Why not use a chart inside Excel? Easier.
Moved from Classic VB forum.
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 
-
Oct 9th, 2005, 06:29 PM
#3
Thread Starter
PowerPoster
Re: Mschart and Excel
Thanks RobDog, so would my example query work or would it need to be re-written?
VB Code:
SELECT * FROM WorkSheetName Range A1 to A1000
Also, if the spreadsheet was already open would it be a problem when connecting to it? If so, is there a way around it since it will be open when I want to run the query?
Last edited by lintz; Oct 9th, 2005 at 07:35 PM.
-
Oct 9th, 2005, 09:19 PM
#4
Re: Mschart and Excel
Its no problem.
You would want to use a querystring like this...
VB Code:
SELECT * FROM [Sheet1$A1:A1000]
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 
-
Oct 10th, 2005, 01:06 AM
#5
Thread Starter
PowerPoster
Re: Mschart and Excel
I found the connection string from www.connectionstrings.com and this is what I've got. However it attempts to open up the spreadsheet again even though it's already open.
VB Code:
xlPath = App.Path & "\Research.xls"
strCn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & xlPath & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
sSQL = "SELECT DrawDown FROM [Trades Database$EG34:EG" & LastRow & "]"
rsSelectedTrades.Open sSQL, strCn 'This line attempts to open the spreadsheet again.
-
Oct 10th, 2005, 01:07 AM
#6
Re: Mschart and Excel
What do you mean "attempts"? Visibly opens another instance or errors?
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 
-
Oct 10th, 2005, 03:28 AM
#7
Thread Starter
PowerPoster
Re: Mschart and Excel
Yes, visibly opens another instance so I then have two copies of my spreadsheet open....
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
|