Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return focus to app, then send a command?

Status
Not open for further replies.

PZero

IS-IT--Management
Jan 16, 2006
28
GB
Hi, I have a button in an access database. When I press the button I want to focus on another application, then send a command to it. Is this possible?

My exact requirements are to press the button at which point some vba will run. The vba will check to see if autocad is open. If not open, it will open it and tell it to run a script. If it is already open, it will switch focus to autocad, then tell it to run the script.
 
Unfortunately I need to with the VBA in Acess, which deosn't support AutoCAD VBA.
 
I am confused. Why can you not:

Set A2K = CreateObject("AutoCAD.Application")

Or

Set A2K = GetObject(,"AutoCAD.Application")

And continue with A2K from there?
 
A better explanation of what I want to do is below;

I have a button on a form and I need it to do the following -

[ol][li]Check if AutoCAD is running[/li]
[li]If AutoCAD is running, maximise it and move the focus to it[/li]
[li]If AutoCAD is not running, start it and move the focus to it[/li][/ol]

I'm thinking this should be fairly simple, but I'm stuck fast and the deadline is looming. Can anyone please help?
 
If
Set A2K = GetObject(,"AutoCAD.Application")
Returns an error, Autocad is not running. A parallel example:

Code:
On Error Resume Next
Set w = GetObject(, "Word.Application")
If Err.Number > 0 Then
    Set w = CreateObject("Word.Application")
End If
On Error GoTo 0
w.Visible = True
w.Activate

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top