Using FindWindow() API to find MSProject and using GetObject

W

WGHayes

Is it possible to find the handle to an existing MS Project application
running.

I have used the FindWindow() API as follows:-

hWnd = FindWindow("JWinproj-WhimperMainClass", 0)

I used an EXCEL example (using XLMAIN) and this works okay however the
'JWinproj-WhimperMainClass' call does not (i.e. I found this documented for
Project 98 and 2000).

I have also been using GetObject(Class:="MSProject.Project") when MS Project
is already running however this does not work either? (error 429 -
automation error)

My requirement is to determine if MS Project is running and to GET the
existing handle or CREATE a new handle.

Anyone with any ideas or who has done this?

Thanks,
WGH.
 
R

Rod Gill

Hi,

In VBA (EG Excel VBA) I always use the following with great success

Dim ProjApp as MSProject.Application

on error resume next
Set ProjApp=GetObject(,"MSProject.Application")
if ProjApp is nothing then
set ProjApp=New MSProject.Application
ProjApp.Visible=True
End if

--
For VBA posts, please use the public.project.developer group.
For any version of Project use public.project
For any version of Project Server use public. project.server

Rod Gill
Project MVP
For Microsoft Project companion projects, best practices and Project VBA
development services
visit www.projectlearning.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top