OK Who can help me with creating graphs from Excel in VB?? OR even better yet sending data from Recordsets to a spreadsheet in Excel then creating a graph from that data??
If you can help me with this you are goooood.
OK Who can help me with creating graphs from Excel in VB?? OR even better yet sending data from Recordsets to a spreadsheet in Excel then creating a graph from that data??
If you can help me with this you are goooood.
As for how to send data to excel...
As for then creating a chart from that data I have nothing to offer. I'd suggest doing a search on the forums since someone has probably already asked that at some point.Code:dim lngRow as long dim objExcel as Excel.Application dim objWorkBook as Excel.WorkBook dim objWorkSheet as Excel.WorkSheet ' open your excel file set objExcel = New Excel.Application set objWorkBook = objExcel.WorkBooks.Open ("C:\Excel.xls") ' this assumes that you have at least one worksheet set objWorkSheet = objWorkBook.WorkSheets(1) ' retrieve the data - i'm assuming you'll put all your code here to open the database connection etc... rsData = "SELECT * FROM customers" ' loop through the data Do While Not rsData.EOF ' increment your row number lngRow = lngRow + 1 ' write the information to the worksheet objWorkSheet.Cells(lngRow,1) = rsData("name") objWorkSheet.Cells(lngRow, 2) = rsData("date") objWorkSheet.Cells(lngRow, 3) = rsData("total_purchased") rsData.MoveNext Loop ' save and close the file objWorkBook.Save objWorkBook.Close ' cleanup set objWorkSheet = nothing set objWorkBook = nothing set objExcel = nothing ' close the recordset, etc...
Hope it gives you a starting point...
Achichincle
VB6 (VSEE SP5, W2KPro)
ASP
HTML
Achichincle
Yes, I'm having a similar problem. Your code that you offered, does this require Excel to be present on the computer to run it, also does this cover all versions of Excel?
Rgds,
Dave R
Bootie,
This was from so long ago I don't really remember a whole lot. Looks like I was using the Excel object so yes, it does require that Excel be installed on the machine running the code.
I've done similar stuff since, but still haven't done any graphing.
Good luck.
Achichincle
VB6 (VSEE SP5, W2KPro)
ASP
HTML
Create a macro in Excel, and copy it into a VB app. It may require some alteration before it runs, but it show you what you need to do.
Moved from Classic VB.![]()
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 (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Star Wars Gangsta Rap • Reps & Rating Posts • VS.NET on Vista (New) • Multiple .NET Framework Versions (New) • 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 Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007