
set focus back to access after automation
Hi,
i use automation to open excel to get some info and put it in a access form
everthing works perfect accept that the focus stays on the excel worksheet
how do i set the focus back to access ?
Ed
Public Function refnr(StrTekst As String, StrKlant As String) As String
Dim mobjExcelApp As Excel.Application
If fIsAppRunning("Excel") Then
Set mobjExcelApp = Excel.Application
Else
Set mobjExcelApp = New Excel.Application
End If
With mobjExcelApp
.Visible = True
.Workbooks.Open ("f:\data\algemeen\referentienrs\8wv")
.Range("b6").Select
.Selection.End(xlDown).Select
.Selection.Offset(1, -1).Select
refnr = .ActiveCell.value
.Selection.Offset(0, 1).Select
.ActiveCell.value = StrKlant
.Selection.Offset(0, 1).Select
.ActiveCell.value = Date
.Selection.Offset(0, 1).Select
.ActiveCell.value = StrTekst
.Selection.Offset(0, 1).Select
.ActiveCell.value = "off/ET"
.ActiveWorkbook.Close (True)
End With
Set mobjExcelApp = Nothing
End Function