set focus back to access after automation 
Author Message
 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



Tue, 22 Mar 2005 21:14:06 GMT  
 set focus back to access after automation
Check Access VB Help on the AppActivate Method.

--
HTH
Van T. Dinh
MVP (Access)


Quote:
> 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



Wed, 23 Mar 2005 00:28:30 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Set Focus back on field (Access 2000 form)

2. Setting focus back after entering carrige return

3. Setting focus back to a text field

4. passing forms and controls so I can set focus back to a form from a module

5. passing forms and controls so I can set focus back to a form from a module

6. Anyway to set focus back on LostFocus?

7. Set focus back to another application

8. Setting focus back to MDI-form

9. Setting focus back to calling app

10. Setting focus to another frame keeps returning focus to the calling routine

11. Getting Focus Back

12. Bring focus back to Word

 

 
Powered by phpBB® Forum Software