My project is moving along smoothly- I've gotten a lot of info from this forum. One thread that helped me understand what I was doing is here. But I have a question I can't find an answer to.
My form fields will populate an Excel workbook. No problems there. My question is how do I call it to enter the data into an Excel template I have already created?
The location of the template sits in my C drive- C:\DailyLogs\Da ilyLog.xlsx
Here's my code so far:
Any ideas?
Thanks,
Rob
My form fields will populate an Excel workbook. No problems there. My question is how do I call it to enter the data into an Excel template I have already created?
The location of the template sits in my C drive- C:\DailyLogs\Da ilyLog.xlsx
Here's my code so far:
Code:
' Here we go. All the data in the form to an Excel sheet. Cross your fingers...
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
'Start a new workbook in Excel- this isn't really what I need though, I need it to open a template and populate it.
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
'Add data to cells of the first worksheet in the new workbook
oSheet = oBook.Worksheets(1)
oSheet.Range("A4").Value = Start1.Text
oSheet.Range("B4").Value = End1.Text
oSheet.Range("C4").Value = Time1.Text
oSheet.Range("D4").Value = CallType1.Text
oSheet.Range("E4").Value = Description1.Text
'etc....
'Save the Workbook and Quit Excel
oBook.SaveAs("C:\DailyLogs\DailyLog.xlsx")
oExcel.Quit()
Thanks,
Rob
Comment