How to switch from an Office application to another programmatical

B

Bernard

Hi all,
Have written an Outllook 2003 VBA macro to initiate a new Access 2003 Form
like this one:
---------
Sub AddAccessRecord()
Dim objAccess As Access.Application
Dim objForm As Access.Form

Set objAccess = GetObject(, "Access.Application") 'get current Database
objAccess.DoCmd.OpenForm "frmMyForm", acNormal, , , acFormAdd 'open Form
Set objForm = objAccess.Forms("frmMyForm") 'assign the local Object
variable
'Form settings code starts here
'.....
'Form settings code stops here
objForm.Visible = True 'set the access form visible
objForm.SetFocus ' with the focus

Set objForm = Nothing
Set objAccess = Nothing
End Sub
---------
This works like a charm but to go ahead with the Access form and finish the
transaction there, I've to switch (manually) from the Outllook application to
the Access one using the Taskbar or playing with the <Alt><Tab> key command.

How can this be done programmatically?
Is it possible to access the taskbar (to switch applications) using VBA code?
What I want is to make the Access Application the Active one (the one who
has the Focus) on top of the screen from my Outllook code.

an 'ObjAccess.Visible = True' statement returns an error....

Any help will be appreciated.
 
D

Dr. Stephan Kassanke

Bernard said:
Hi all,
Have written an Outllook 2003 VBA macro to initiate a new Access 2003 Form
like this one:
---------
Sub AddAccessRecord()
Dim objAccess As Access.Application
Dim objForm As Access.Form

Set objAccess = GetObject(, "Access.Application") 'get current
Database
objAccess.DoCmd.OpenForm "frmMyForm", acNormal, , , acFormAdd 'open
Form
Set objForm = objAccess.Forms("frmMyForm") 'assign the local Object
variable
'Form settings code starts here
'.....
'Form settings code stops here
objForm.Visible = True 'set the access form visible
objForm.SetFocus ' with the focus

Set objForm = Nothing
Set objAccess = Nothing
End Sub
---------
This works like a charm but to go ahead with the Access form and finish
the
transaction there, I've to switch (manually) from the Outllook application
to
the Access one using the Taskbar or playing with the <Alt><Tab> key
command.

How can this be done programmatically?
Is it possible to access the taskbar (to switch applications) using VBA
code?
What I want is to make the Access Application the Active one (the one who
has the Focus) on top of the screen from my Outllook code.

an 'ObjAccess.Visible = True' statement returns an error....

Any help will be appreciated.

Hi Bernard,

did you try objAccess.Activate?

Stephan
 
B

Bernard

Hi Stephan,

I'm afraid that the Activate method is not applicable to an Access
Application object.... however in a similar way I find a VBA function called
AppActivate ....and it works :)
this is the complete statement:
......
objForm.Visible = True 'set the access form visible
objForm.SetFocus ' with the focus

AppActivate "Microsoft Access" 'Activates the Access application Windows

Set objForm = Nothing
Set objAccess = Nothing
End Sub

Thank you Stephan for the inspiration you have given me.

Cheers,
Bernard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top