Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / September 2007



Tip: Looking for answers? Try searching our database.

Sensing if an application is busy

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MAB - 22 Sep 2007 01:24 GMT
I'm connecting to an application via GetObject.  The problem is, if the
application is busy doing something (like editing a cell in Excel), GetObject
fires up a busy dialog (Switch To... or Retry).  Is there a way to test if an
application is running and if it busy before I attempt to connect to it via
GetObject?
Ralph - 22 Sep 2007 02:23 GMT
> I'm connecting to an application via GetObject.  The problem is, if the
> application is busy doing something (like editing a cell in Excel), GetObject
> fires up a busy dialog (Switch To... or Retry).  Is there a way to test if an
> application is running and if it busy before I attempt to connect to it via
> GetObject?

What Error handling do you have in place now?

If none try this...
[ Warning! Air Code!]

On Error Resume Next
Set p = GetObject(, "MS.Application")
       ' Determine if already running.
If Not p Is Nothing Then
     MsgBox "Microsoft Application is already running"
     ' do something else
Else
     ' go about your business
End If

-ralph
MAB - 22 Sep 2007 15:02 GMT
On Error Resume Next

Actually GetObject connects with Excel properly but when I try get the
active document, I receive the Component Busy dialog (Switch To..., Retry,
Cancel).

Set moActiveDoc = goHostApp.ActiveWorkbook

So, VB is not erroring out, it just stuck in a infinate loop (unless I go
Excel and Esc out of editing the cell).  So, the question is, is there a way
to sense if the application object is busy or not before you request
something of it.

Thanks the help Ralph.

> > I'm connecting to an application via GetObject.  The problem is, if the
> > application is busy doing something (like editing a cell in Excel),
[quoted text clipped - 21 lines]
>
> -ralph
Ralph - 22 Sep 2007 16:23 GMT
> On Error Resume Next
>
[quoted text clipped - 10 lines]
>
> Thanks the help Ralph.

But, again, ARE you using error-handling?

IIRC, this error is usually caught with error-handling, or perhaps there is
something else that needs to be configured. Have to go back and check some
of my stuff.

-ralph
MAB - 22 Sep 2007 16:52 GMT
I did not but the effect is eccentually the same if I do.  Meaning, the error
handler is only triggered after the user presses the Cancel but which breaks
the loop otherwise it keeps trying forever (occationally timing out which
pops up the busy dialog).

On Error GoTo stuck
Set moActiveDoc = goHostApp.ActiveWorkbook
GoTo bypass

stuck:
MsgBox Err.Description
End

bypass:
On Error Resume Next

> > On Error Resume Next
> >
[quoted text clipped - 19 lines]
>
> -ralph
Ralph - 22 Sep 2007 19:49 GMT
> I did not but the effect is eccentually the same if I do.  Meaning, the error
> handler is only triggered after the user presses the Cancel but which breaks
[quoted text clipped - 11 lines]
> bypass:
> On Error Resume Next

Is this a situation where both the App and the User are chewing on something
at the same time?

-ralph
MAB - 22 Sep 2007 20:04 GMT
Yes sir.  The user has an Excel spread sheet open and is editing the cell.  
The user leaves Excel in this state and launches my app which use GetObject
to connect to Excel (which successful) then attempts to connect to the active
document in Excel but it can't because the document is busy editing a cell.

> > I did not but the effect is eccentually the same if I do.  Meaning, the
> error
[quoted text clipped - 18 lines]
>
> -ralph
Mark Yudkin - 30 Sep 2007 09:35 GMT
Please review the App object's OLERequestPending* and OLEServerBusy*
properties in the VB6 documentation.

> I'm connecting to an application via GetObject.  The problem is, if the
> application is busy doing something (like editing a cell in Excel),
[quoted text clipped - 4 lines]
> via
> GetObject?
MAB - 30 Sep 2007 22:26 GMT
Thank you Mark, that is helpful.

> Please review the App object's OLERequestPending* and OLEServerBusy*
> properties in the VB6 documentation.
[quoted text clipped - 7 lines]
> > via
> > GetObject?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.