Access VBA: Write to a Specific Open Excel Workbook and Worksheet
Question details
Use Access VBA to write data to a named worksheet in an already open Excel workbook.

- Product
- Microsoft Access and Microsoft Excel
- Device & OS
- not provided
- Scenario
- An Access VBA procedure needs to use an existing Excel instance and workbook instead of creating a new workbook.
- Observed behavior
- The procedure should select the specified open workbook and worksheet, then write a value to a cell.
Open the target workbook in Excel and check its exact file name, extension, and worksheet tab name. Make sure you can run VBA code in the Access database.
Connect to the open Excel workbook with GetObject
Use this method when Excel and the target workbook are already open.
GetObject attaches to a running Excel application. The workbook must be open in the Excel instance returned by GetObject; if multiple instances are running, it may not be in the instance you expect.
In Access, press Alt+F11 and open an existing module or choose Insert > Module.
Paste this example into the module: Sub WriteToOpenExcelSheet() Dim xlApp As Object Dim xlWbk As Object Dim xlWsh As Object Set xlApp = GetObject(Class:="Excel.Application") Set xlWbk = xlApp.Workbooks("Template.xlsx") Set xlWsh = xlWbk.Worksheets("Data") xlWsh.Range("A1").Value = "Example value" End Sub
Replace Template.xlsx with the exact name of your open workbook, including its extension, and replace Data with the worksheet tab name. Use .xlsm if that is the workbook's actual extension.
Place the cursor inside the procedure and press F5. In Excel, check cell A1 on the selected worksheet, then save the workbook if you want to keep the change.

Edit Excel Workbooks with WPS Spreadsheet
WPS Office is a free, lightweight alternative with a familiar interface for opening and editing compatible Excel workbooks. It supports migration of common spreadsheet files, but it does not fix or replace Access VBA automation of Microsoft Excel.

Frequently Asked Questions
Does GetObject open the workbook if it is closed?
No. In this example, GetObject connects to a running Excel application, and Workbooks("Template.xlsx") selects a workbook already open in that instance.
Do I need to add an Excel reference in Access?
No. The example declares the Excel objects As Object, so it uses late binding and does not require an Excel object library reference.
Why can't VBA find my open workbook?
Check the exact file name and extension in the Workbooks call. If multiple Excel instances are running, the workbook may be open in a different instance from the one returned by GetObject.
How do I write to a different cell?
Change the address in xlWsh.Range("A1").Value, for example to xlWsh.Range("B2").Value, and assign the value you want.
Does the code save or close the workbook?
No. The example only changes a cell. Use Excel's Save command to keep the change; it leaves the existing workbook and Excel instance open.




