Вы не предоставляете много информации о своем требовании, так что это всего лишь введение. Я могу предоставить больше информации, если вы делаете.
В редакторе Access VBA выберите Tools
, затем References
. Прокрутите вниз до Microsoft Excel 11.0 Object Library
и выберите его, щелкнув поле напротив него.
Скелет необходимого кода:
Dim Path As String
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
' I hold my Excel file in the same folder asmy Access database.
' This gets me the name of the folder holding my database.
Path = Application.CurrentProject.Path
' I assume the Excel file already exists
DestName = Path & "\" & "xxxxxxxx.xls"
Set xlApp = New Excel.Application
With xlApp
.Visible = True ' This slows your macro but helps during debugging
'.Visible = False
Set xlWB = .Workbooks.Open(DestName)
With xlWB
With .Sheets("Sheet1")
' Intro to syntax
' * .Cells(Row,Column) gives access to any cell within the sheet.
' * .Cells(Row,Column).Value gives read/write access to the value.
' * .Cells(Row,Column).Font.Bold = True sets the cell to bold.
' * RowLast = .Cells(Row.Count,"A").End(xlUp).Row get the number of the
' last used row in column A.
.Cells(1, 1).Value = "A"
' More statements here
End With
.Save ' Save updated workbook to disc
.Close ' Close workbook
End With
Set xlWB = Nothing ' Clear reference to workbook
.Quit ' Exit Excel
End With
Set xlApp = Nothing ' Clear reference to Excel