Writing Data in Excel format

Hi, I have some data that I'd like to write in an Excel spreadsheet directly from my VB program.

Can somebody give me some sample code to add the text in a cell for example?

Thanks
mikemonnexAsked:
Who is Participating?
 
mayhewConnect With a Mentor Commented:
Dim app As Excel.Application
     
'Create instance of Excel object.
Set app = New Excel.Application
     
'Make app visible so you can see what happens.
app.Application.Visible = True

'Open an existing workbook.
app.Workbooks.Open app.Path & "\" & "MyWorkbook.xls"

'Select a sheet.
app.Application.Sheets("Daily").Select

'Select a cell.
app.Application.Range("C11").Select

'Enter some data.
app.Application.ActiveCell.Value = "Whatever you want."

'Save the workbook.
app.Application.Workbooks(1).Save

'Or save as a different workbook.
app.Application.Workbooks(1).SaveAs

'Close the workbook.
app.Application.Workbooks(1).Close

'Close the app.
app.Application.Quit
Set app = Nothing




0
All Courses

From novice to tech pro — start learning today.