Jump to content

Trap a Fatal Error


dSchnader
 Share

Recommended Posts

Hi

I have a script that reads and processes a Microsoft Project plan. For Project 2003, the script worked ok. Now with Project 2010, the plan "could" be connected to the Team Foundation Server. If that is the case, there may be some time before a TFS signon pops up. Until I get past that signon, I can't work with my project object.

Here is a simple test script. I run project and open the plan. I wait 5 seconds for a resource pool prompt. If I get that I cancel it. If I didn't get the pool prompt I check for a file in use prompt. If I get that I Alt-r it for Read-Only mode. And check again for the pool.

Now the TFS junk.

I can create a project object. "If IsObj($oProject)" would pass its test. "If IsObj($oProject.Projects)" will not pass the test for a TFS connected project. In fact it fails with a fatal error.

I can put in code to handle the TFS signon. I just can't tell if I am waiting for that prompt to appear. I don't want to wait an indefinate amount of time for the prompt.

What I would like to do is loop around waiting for the $oProject.Projects object to appear. If the $oProject.Projects object appears, great! the script moves on. If a TFS prompt appears, no problem I can handle it.

I just don't need the script to stop for the fatal error.

;---------------------------------------------------- Work with MS Project

Func OpenProject($plnpath)

Run('C:\Program Files (x86)\Microsoft Office\Office14\WINPROJ.EXE "' & $plnpath & '"')

If @error <> 0 Then MsgBox(0,"Error", "Project plan open error is:" & @error & "-" & @extended)

If WinWaitActive("Open Resource Pool", "", 5) Then

Send("{ESC}")

Else

If WinWaitActive("File in Use", "", 5) Then

Send("!r")

If WinWaitActive("Open Resource Pool", "", 5) Then

Send("{ESC}")

EndIf

EndIf

EndIf

$oProject = ObjCreate("MSProject.Application")

;--------------------------------------- Would make a loop here to wait for the project object

;----- simple test to see if it worked. non-TFS works. TFS connected fails.

if not IsObj($oProject.Projects) then

Msgbox(0,"Error","$oProject is not an Object.")

else

Msgbox(0,"Error","Successfully created Object $oShell.")

endif

;------ new code to handle TFS

If WinWaitActive("Connecting to", "", 5) Then

Send("{ESC}")

If WinWaitActive("Microsoft Office Project", "connect to", 5) Then

Send("{ESC}")

EndIf

EndIf

;--------------------------------------------------- End of loop

EndFunc

Thanks

Donald

PS personal rant: As I read through the forum, I occasionally see responses saying: "'I' would not even be trying to do this" or "you just should not do this" or "if you coded it right you would not have this problem". If that was your response, just don't respond to my post. I get really tried of having to sort through the noise. Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...