By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,376 Members | 3,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,376 IT Pros & Developers. It's quick & easy.

Automation and Word 2007

P: n/a
I'm using the following code to check whether Word is running:

Function IsAppRunning(strAppname As String) As Boolean
Dim strClassName As String
Select Case LCase$(strAppname)
Case "Excel": strClassName = "XLMain"
Case "Outlook": strClassName = "MSOutlook"
Case "Word": strClassName = "OpusApp"
Case Else: strClassName = ""
End Select
IsAppRunning = apiFindWindow(strClassName, vbNullString) <0

If True, I use GetObject else CreateObject.
I've noticed recently that it returns true if Outlook is open and Outlook is
using Word as an email editor, even if an instance of Word is not open in
its own right.
This doesn't seem to be a problem with Office XP, but a new client using
Word 2007, with my AccessXP runtime gets an error "Active X component can't
create object (Error 429) ....".
Is there a newer version of IsAppRunning which could identify this problem,
or am I stuck with trapping Error 429 and using CreateObject?
--
Bob Darlington
Brisbane
Jul 25 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Wed, 25 Jul 2007 16:25:41 +1000, "Bob Darlington"
<bo*@dpcmanAX.com.auwrote:

MSFT never promised that classnames would stay the same.

I would remove the FindWindow test altogether, and go straight to
GetObject. If it fails, the object is not there, and CreateObject
would be the next step.

-Tom.

>I'm using the following code to check whether Word is running:

Function IsAppRunning(strAppname As String) As Boolean
Dim strClassName As String
Select Case LCase$(strAppname)
Case "Excel": strClassName = "XLMain"
Case "Outlook": strClassName = "MSOutlook"
Case "Word": strClassName = "OpusApp"
Case Else: strClassName = ""
End Select
IsAppRunning = apiFindWindow(strClassName, vbNullString) <0

If True, I use GetObject else CreateObject.
I've noticed recently that it returns true if Outlook is open and Outlook is
using Word as an email editor, even if an instance of Word is not open in
its own right.
This doesn't seem to be a problem with Office XP, but a new client using
Word 2007, with my AccessXP runtime gets an error "Active X component can't
create object (Error 429) ....".
Is there a newer version of IsAppRunning which could identify this problem,
or am I stuck with trapping Error 429 and using CreateObject?
Jul 25 '07 #2

P: n/a
On Jul 25, 2:25 am, "Bob Darlington" <b...@dpcmanAX.com.auwrote:
I'm using the following code to check whether Word is running:

Function IsAppRunning(strAppname As String) As Boolean
Dim strClassName As String
Select Case LCase$(strAppname)
Case "Excel": strClassName = "XLMain"
Case "Outlook": strClassName = "MSOutlook"
Case "Word": strClassName = "OpusApp"
Case Else: strClassName = ""
End Select
IsAppRunning = apiFindWindow(strClassName, vbNullString) <0

If True, I use GetObject else CreateObject.
I've noticed recently that it returns true if Outlook is open and Outlook is
using Word as an email editor, even if an instance of Word is not open in
its own right.
This doesn't seem to be a problem with Office XP, but a new client using
Word 2007, with my AccessXP runtime gets an error "Active X component can't
create object (Error 429) ....".
Is there a newer version of IsAppRunning which could identify this problem,
or am I stuck with trapping Error 429 and using CreateObject?
--
Bob Darlington
Brisbane
Thanks for the warning. For Word, maybe always use just CreateObject
for your purpose and leave any other running instances of Word alone.

James A. Fortune
CD********@FortuneJames.com

Jul 25 '07 #3

P: n/a
Thanks Tom.
Will do that.

--
Bob Darlington
Brisbane
"Tom van Stiphout" <no*************@cox.netwrote in message
news:qc********************************@4ax.com...
On Wed, 25 Jul 2007 16:25:41 +1000, "Bob Darlington"
<bo*@dpcmanAX.com.auwrote:

MSFT never promised that classnames would stay the same.

I would remove the FindWindow test altogether, and go straight to
GetObject. If it fails, the object is not there, and CreateObject
would be the next step.

-Tom.

>>I'm using the following code to check whether Word is running:

Function IsAppRunning(strAppname As String) As Boolean
Dim strClassName As String
Select Case LCase$(strAppname)
Case "Excel": strClassName = "XLMain"
Case "Outlook": strClassName = "MSOutlook"
Case "Word": strClassName = "OpusApp"
Case Else: strClassName = ""
End Select
IsAppRunning = apiFindWindow(strClassName, vbNullString) <0

If True, I use GetObject else CreateObject.
I've noticed recently that it returns true if Outlook is open and Outlook
is
using Word as an email editor, even if an instance of Word is not open in
its own right.
This doesn't seem to be a problem with Office XP, but a new client using
Word 2007, with my AccessXP runtime gets an error "Active X component
can't
create object (Error 429) ....".
Is there a newer version of IsAppRunning which could identify this
problem,
or am I stuck with trapping Error 429 and using CreateObject?

Jul 25 '07 #4

P: n/a
Thanks for the reply James.
The problem is that my code creates up to 40 Word merge letters and a single
command. So I don't want to open 40 instances of Word.
I'll run with Tom's suggestion for the time being.
--
Bob Darlington
Brisbane
<CD********@FortuneJames.comwrote in message
news:11*********************@22g2000hsm.googlegrou ps.com...
On Jul 25, 2:25 am, "Bob Darlington" <b...@dpcmanAX.com.auwrote:
>I'm using the following code to check whether Word is running:

Function IsAppRunning(strAppname As String) As Boolean
Dim strClassName As String
Select Case LCase$(strAppname)
Case "Excel": strClassName = "XLMain"
Case "Outlook": strClassName = "MSOutlook"
Case "Word": strClassName = "OpusApp"
Case Else: strClassName = ""
End Select
IsAppRunning = apiFindWindow(strClassName, vbNullString) <0

If True, I use GetObject else CreateObject.
I've noticed recently that it returns true if Outlook is open and Outlook
is
using Word as an email editor, even if an instance of Word is not open in
its own right.
This doesn't seem to be a problem with Office XP, but a new client using
Word 2007, with my AccessXP runtime gets an error "Active X component
can't
create object (Error 429) ....".
Is there a newer version of IsAppRunning which could identify this
problem,
or am I stuck with trapping Error 429 and using CreateObject?
--
Bob Darlington
Brisbane

Thanks for the warning. For Word, maybe always use just CreateObject
for your purpose and leave any other running instances of Word alone.

James A. Fortune
CD********@FortuneJames.com

Jul 25 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.