Can The Task Information Dialog Be Closed?

C

Chris Molland

Hello,

I am developing a VB application which reads information from a Project
file. However if the user has the Task Information dialog box open when my
method is called to read the Task information I get an error.

Is it possible to check if it is open and if it is close the Task
Information dialog box. I can see that it can be opened using:

oProjApp.InformationDialog

Many thanks.

Chris
 
J

Jan De Messemaeker

Why read the task information dialog? Normally you directly address the
properties of the task object: ther eis nothing in the task information
dialog taht cannot be addressed via the task object.
For instance, which info are you after?

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 
C

Chris Molland

Hi Jan,

I do read the values directly, as you suggest. However the user can view and
edit the Project file at the same time as using my application, in fact they
are encouraged to!

Because of this they may have left the Task Information dialog open and
clicked back on my application's Form. When the user clicks on my
application's Form it immediately reads all the Tasks from MS Project in case
any of the values have changed. If the Task Information Dialogue is open my
application can't get access to the Task data and an error is thrown. This is
why I want to check if it is open and if it is close it.

Thank you.
 
J

Jack Dahlgren

The task information box is modal. That means you can't do anything in the
application while it is open. So I'd just put in an error handler which pops
up a message box telling the user to close that window or perhaps inactivate
your form or turn the background red.

I don't think there is an easier way of doing this.

There may be a way to do it if you throw in some windows calls and find the
handle of the window and close it, but I couldn't tell you how to go about
that.

-Jack Dahlgren
 
C

Chris Molland

Thank you very much Jack.

I will initially catch the exception and warn the user as you suggest. It
would be neat to close the dialog but it seems as if it may be difficult.

Regards
 
J

John

Jack Dahlgren said:
The task information box is modal. That means you can't do anything in the
application while it is open. So I'd just put in an error handler which pops
up a message box telling the user to close that window or perhaps inactivate
your form or turn the background red.

I don't think there is an easier way of doing this.

There may be a way to do it if you throw in some windows calls and find the
handle of the window and close it, but I couldn't tell you how to go about
that.

-Jack Dahlgren
Jack,
I'm just guessing here because I've never done stand alone VB but could
he detect the error using "on error resume next" and then initiate a
"sendkeys" command?

John
 
J

Jack Dahlgren

John,

The behavior of send keys in that case would be pretty unpredictable. What
if the cursor was in the task name box? Or duration? Or Notes? What would
happen?
Letting the user control it would seem to be the best choice. Only the user
knows what they want to happen.

-Jack Dahlgren
 
J

John

Jack Dahlgren said:
John,

The behavior of send keys in that case would be pretty unpredictable. What
if the cursor was in the task name box? Or duration? Or Notes? What would
happen?
Letting the user control it would seem to be the best choice. Only the user
knows what they want to happen.

-Jack Dahlgren

Jack,
OK then, not such a good idea.

Thanks for the insight. Actually, I've never messed with the "sendkeys"
command.

John
 
C

Chris Molland

Thank you for considering this situation John.

Just as a thought is there any way to test if the Task Information Dialog is
open? I would prefer to check for the dialog box being displayed rather than
rely on catching an exception.

I tried looping through both the application and active project windows but
clearly these collections do not include the dialog box. Is there a property
I can test.

Once I have established that the dialog is open I will inform the user with
a message box to close it before proceding.

Thank you.
 
J

John

Chris Molland said:
Thank you for considering this situation John.

Just as a thought is there any way to test if the Task Information Dialog is
open? I would prefer to check for the dialog box being displayed rather than
rely on catching an exception.

I tried looping through both the application and active project windows but
clearly these collections do not include the dialog box. Is there a property
I can test.

Once I have established that the dialog is open I will inform the user with
a message box to close it before proceding.

Thank you.

Chris,
No, not anything that I am aware of. Over the years that I have been
writing Project VBA there have been several instances where the only
approach was an indirect one (e.g. is the hierarchy collapsed or
expanded?, are custom font characteristics applied?, etc.).

I thought the SendKeys approach might work and it would if the user had
only just opened the Task Information dialogue without making any
changes. However, Jack pointed out the uncertainty of using SendKeys in
that instance and Jack's experience goes way beyond mine.

Bottom line, the "on error resume next" with a user message appears to
be the best approach.

John
Project MVP
 
J

Jack Dahlgren

Sending the escape key should close the box, my point is that it closes
without saving what they were working on.

Sending enter saves what they were working on, but maybe they typed
something by accident.

Enter, while they are editing some fields can cause warning dialogs to
display, then how do you deal with them?

So you can attempt it, but how would you know which behavior your user is
expecting? The reason that dialog box is modal (can only use it when it is
open) is because of these very sorts of scenarios.

-Jack Dahlgren
 
S

Scudder

Chris, the dialogue box is class JWinproj-MLSDialog, you'll need to use API
calls to find the window if it is open by obtaining it handle.

BUT - you'll encounter the same problem if other controls have focus, such
as the text edit box, if it has focus then add-ins and process code can fail.

It's probably simpler to just catch the error.
 

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