在Access中,我们需要把数据写入到excel中
下面分享个示例,把数据写入到指定的单元格中:详细代码如下
Dim xlApp As Object
Dim xlWbk As Excel.Workbook
Dim xlWsh As Excel.Worksheet
Set xlApp = GetObject(, "Excel.Application")
xlApp.Visible = True
Set xlWbk = xlApp.Workbooks.Open(CurrentProject.Path & "\示例1.xlsx")
Set xlWsh = xlWbk.Worksheets(1)
xlWsh.Activate
xlWsh.Range(txtRange).Value = Me.txt1 '在指定单元格中输入文本框中的内容
xlWbk.Save '保存
Set xlWsh = Nothing
Set xlWbk = Nothing
Set xlApp = Nothing