2 of 2 people found this helpful
I did some tests with your code and I believe that this is expected. In the code, you are opening a blank workbook with: Set oBook = oExcel.Workbooks.Add. After the cells have been updated by objects in Processbook, you Save the workbook using the SaveAs Function. The SaveAs function checks the file path to see if there is an existing spreadsheet and will prompt you to see if you'd like to overwrite the file (AKA delete and create a new file)
I made some modifications to the code. Please give this a try:
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Open("H:\File.xlsx")
'Add data to cells of the first worksheet in the new workbook
Set oSheet = oBook.Worksheets(1)
oSheet.Range("B2").Value = txtField1.Value
oSheet.Range("C2").Value = txtField2.Value
'Save the Workbook and Quit Excel
This should open the existing file and save it.
Please let me know if this works.
Thank you for the quick reply.
I just tried it and it works perfect. This is one of the best community group I've ever joined.