Manipulating an Excel spreadsheet from an Access module

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Where can I find an example of vba code to open an existing excel
spreadsheet, enter text in a cell and 'save as' to save that spreadsheet?
 
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet

Set oBook = GetObject("D:\Folder\FileName.xls")
Set oSheet = oBook.Worksheets("Sheet1")

oSheet.Range("G8").Value = 999

Set oSheet = Nothing

oBook.Windows(1).Visible = True
oBook.SaveAs "D:\Folder\NewName.xls"
oBook.Close False
Set oBook = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top