Checking for Active Word App 
Author Message
 Checking for Active Word App

Hi

I have a program that requires the opening of Excel and
Word files. On Error, the Routine goes to and Error
handler that displays the error msg and tries to save and
close both word and excel files.
The problem occurs when the Error takes place on opening
the word or excel file. Upon the occurance of the Error,
it goes to the error handler, displays the msg and then
tries to close a file that doesn't exist b/c it couldn't
be openned. I was wondering if there was a way in the
error handler to check to see if a word or excel file or
document is open before trying to close it?

This would stop my program from crashing.

thank you very much in advance

Have you tried using the GetObject function?


Microsoft MVP (Visual Basic)



Sun, 27 Mar 2005 01:36:48 GMT  
 Checking for Active Word App
GetObject asks for a path name of a file and if the file
isn't open, it crashes as well. I need to somehow check to
see if a file, document or workbook IS in fact open in
order to avoid these crashes.

Thank you

Quote:
>-----Original Message-----
>On Tue, 8 Oct 2002 08:47:39 -0700, "Farsad Nasseri"

> Hi
>
> I have a program that requires the opening of Excel and
> Word files. On Error, the Routine goes to and Error
> handler that displays the error msg and tries to save
and
> close both word and excel files.
> The problem occurs when the Error takes place on
opening
> the word or excel file. Upon the occurance of the
Error,
> it goes to the error handler, displays the msg and then
> tries to close a file that doesn't exist b/c it
couldn't
> be openned. I was wondering if there was a way in the
> error handler to check to see if a word or excel file
or
> document is open before trying to close it?
>
> This would stop my program from crashing.
>
> thank you very much in advance

>Have you tried using the GetObject function?


>Microsoft MVP (Visual Basic)
>.



Sun, 27 Mar 2005 02:39:05 GMT  
 Checking for Active Word App

GetObject asks for a path name of a file and if the file
isn't open, it crashes as well. I need to somehow check to
see if a file, document or workbook IS in fact open in
order to avoid these crashes.

Give the following a try:

    Public Function IsExcelRunning()

        Dim oExcelApplication As Excel.Application

        Try
            oExcelApplication = GetObject(, "Excel.Application")
            '...
            '...
            '...
            oExcelApplication.Quit()
            oExcelApplication = Nothing
        Catch
            IsExcelRunning = False
        End Try

    End Function


Microsoft MVP (Visual Basic)



Sun, 27 Mar 2005 02:53:45 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Active program: keeping the app active and checking time

2. Check for active app

3. Closing windows - check for active app

4. Is Word app active?

5. Find out if my app is the active app

6. Checking a check box in Word with VBS

7. Checking a check box in Word with VBS

8. Checking a check box in Word with VBS

9. Word 97 - Closing Word Outside App kills object reference

10. Using Word 6.0 and Word 97 in the same app

11. How to check if WordMail is active?

12. check active document

 

 
Powered by phpBB® Forum Software