Function test()
Dim xlApp As Object
Dim xlwb As Object
Dim db As DAO.Database
Dim fName as string
Set db = CurrentDb
fName = "D:\Dev\ltexttest.XLSX"
db.Execute ("UPDATE (SELECT * FROM [sheet1$A:B] AS xlData IN '" & fName & "'[Excel 12.0;HDR=yes;IMEX=0;ACCDB=Yes]) AS XL SET XL.test = '', XL.dummy = ''", dbFailOnErrror)
db.Close
If Not IsWorkBookOpen(fName) Then 'file not open, so open it
Set xlApp = CreateObject("excel.application")
xlApp.Visible = True
Set xlwb = xlApp.Workbooks.Open(fName)
End If
End Function
Function IsWorkBookOpen(FileName As String) As Boolean
Dim ff As Long, ErrNo As Long
On Error Resume Next
ff = FreeFile()
Open FileName For Input Lock Read As #ff
Close ff
ErrNo = err
On Error GoTo 0
Select Case ErrNo
Case 0: IsWorkBookOpen = False
Case 70: IsWorkBookOpen = True
Case Else: Error ErrNo
End Select
End Function