|
-
Apr 2nd, 2005, 02:50 AM
#1
Thread Starter
Junior Member
How to go about in Importing Excel data into a grid?
Good afternoon
I would like to import data from an Excel file and fill a grid with the data. Any ideas on how to do it?
I would also like to import text from an external source, something like a txt file and import it in to a grid.
eg If I was to copy 20 rows of text, from either an excel file or a txt file and copy it into a grid. Is there a way for the data to be placed into the grid?
I am a novice at Vb6 so any help will be much appreciated. Thank you.
-
Apr 2nd, 2005, 09:41 AM
#2
Re: How to go about in Importing Excel data into a grid?
Welcome to the Forums.
One way would be to have a loop that went through the used range in Excel and place each value in the grid.
VB Code:
Dim oApp as excel.application
dim oWB as excel.workbook
dim iRow as integer
dim iCol as integer
set oapp = new excel.application
set owb = oapp.workbooks.open("C:\Book1.xls")
irow = owb.cells.range.specialcells(xlCellTypeLastCell).Row
icol = owb.cells.range.specialcells(xlCellTypeLastCell).Column
'Todo: loop though the row/columns adding the cells(irow, icol).Value to each cell in your grid.
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 
-
Apr 2nd, 2005, 05:08 PM
#3
Thread Starter
Junior Member
Re: How to go about in Importing Excel data into a grid?
G'day RobDog888.
That makes alot of sense, I havent tried it but it looks like it should work. Brilliant!!
-
Apr 2nd, 2005, 06:28 PM
#4
Re: How to go about in Importing Excel data into a grid?
Thanks, there are a couple of other more complex methods that may be better if your coping allot of records.
Post back if you have any problems with this.
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
|