473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Automation and Word 2007

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
4 4722
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
12
by: Cheval | last post by:
Has anyone had any problems with inter-office automation between MS Word and MS Access in Office 2003? I have recently installed office 2003 in a new folder and have left the older office 2000...
21
by: Neil | last post by:
Is there a way to trap an error generated in another app that is controlled via automation? I have an Access 2000 app that opens Word 2000 and proceeds to open a series of documents and, in each...
22
by: liya.tansky | last post by:
Hello, I'm developing an intranet (win XP, .NET 2, Visual Studio 2005, Microsoft.Office.Interop.Word.dll in references) and needed to implement find-replace in word doc before sending letter and...
0
by: nebbiasun | last post by:
I have a split database which calls a word document (mail merge from query) which works perfectly in both access 2003 and 2007. I have secured the frontend and backend (user level security) in 2003...
8
by: =?Utf-8?B?QmFkaXM=?= | last post by:
I have tried a server-side automation and it's giving me problems that I couldn't solve.. Now, I'm switching to client side automation and I was following this example:...
0
by: ppardi | last post by:
I'm developing an addin for Word 2007 and I need to determine whether a user saves a Word 2007 document in an older format (97-2003) after a save as is done. The scenario is that the user starts...
10
by: cj2 | last post by:
I open a word template in VB and add values to the bookmarks then save the document as as pdf. When I then go to close the document it pops up a save as dialog box. It's already saved the...
2
by: Terry | last post by:
Hello: using vb.net 2005 and word 2007. I would like to open a word.docx document Have a button on a vb.net form that when clicked inserts text on the word document Have a button on a vb.net...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.