|
-
Mar 15th, 2004, 10:20 AM
#1
Thread Starter
Addicted Member
Using ADO to access a closed Excel Spreadsheet
I've been doing searches for awhile, and getting mostly examples like this one:
http://www.exceltip.com/st/Use_a_clo...Excel/432.html
I'm not good with SQL and was hoping to find something simple so I could finish what I'm doing quickly.
I need to connect to a workbook/sheet without opening it and find the last used row(If Cell(1,1) is empty, it will be a blank row). Then on the next row down I need to copy some text into a few columns worth of cells.
If I have to use SQL, I guess I could use some pointers. I learned a tiny bit of it once to get through another project but it gave me a headache and I stink at it 
Oh and I'm actually using 97-VBA if that limits me at all.
Thanks
-
Mar 15th, 2004, 10:54 AM
#2
This willl return the last row with data in it.
VB Code:
MaxRowNumber = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
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 
-
Mar 15th, 2004, 11:03 AM
#3
Here is one of my functions that I wrote with ADO to connect to an
excel spreadsheet.
CnnE = ADO Public connection.
frmMain.lblPath = path/filename to the spreadsheet - can be hard coded.
Function returns true when the connection is made.
VB Code:
Public Function ExcelConnect() As Boolean
'<RR 03/17/03>
On Error GoTo No_Bugs
If CnnE.State = adStateClosed Then
CnnE.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; DATA Source=" & frmMain.lblPath & ";Extended Properties=Excel 8.0;"
CnnE.CursorLocation = adUseClient
CnnE.Open
ExcelConnect = True
Else
CnnE.Close
CnnE.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; DATA Source=" & frmMain.lblPath & ";Extended Properties=Excel 8.0;"
CnnE.CursorLocation = adUseClient
CnnE.Open
ExcelConnect = True
End If
Exit Function
No_Bugs:
ExcelConnect = False
End Function
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 
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
|