I need help with code to import a specific sheet into a datagrid. The .xls file is at C:\test.xls. But only need to pull "sheet1" to the grid. I know this is probably a simple task but Im new and stuck here. Thanx for help!!!
Brian
Printable View
I need help with code to import a specific sheet into a datagrid. The .xls file is at C:\test.xls. But only need to pull "sheet1" to the grid. I know this is probably a simple task but Im new and stuck here. Thanx for help!!!
Brian
ANY IDEAS ANYONE?
I also want to know...
Welcome to the forums. :)
Have you tried searching yet? I have many many code examples with Excel. Try a search for Excel and posts by me. ;)
Seeing how its slow tonight I will write something for you.
VB Code:
Option explicit 'Add a reference to ms excel xx.0 object library Private sub command1_click() dim oApp as excel.application dim oWB as excel.workbook set oapp = new excel.application set owb = oapp.workbooks.open("C:\MyFile.xls") 'instead of a msgbox place looping code to iterate 'through your cell range of data to be entered into your grid. Msgbox owb.sheets("Sheet1").Cells(1, 1) owb.close set owb = nothing oapp.quit set oapp = nothing End sub