Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

excel avd vb

Status
Not open for further replies.

waqasshahid79

Technical User
May 24, 2002
2
PK
i want to connect the excel in vb.just like an access database.
 
One method

Private Sub Sample()
'You'll need to Set Reference to
'Microsoft Excel 9.0 Object Library
Dim xlApp As Object
Dim xlWb As Excel.Workbook
Dim strTmp As String

Set xlApp = CreateObject("Excel.Application")
xlApp.AskToUpdateLinks = False
xlApp.DisplayAlerts = False

Set xlWb = xlApp.Workbooks.Open("C:\Development\Excel\book1.xls")


xlWb.Sheets("Sheet1").Select
strTmp = CStr(xlWb.Sheets("Sheet1").Cells(1, 1).Value)
'or if you rather
'strTmp = Cstr(xlWb.Sheets("Sheet1").Range("A1").value
MsgBox strTmp

xlWb.Close
Set xlApp = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top