Project: Open Dialog Appears Even with Alerts False Command
  
PSS ID Number: Q113507
Article last modified on 03-24-1995
 
4.00    | 4.00
 
WINDOWS | MACINTOSH
 

---------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Project for Windows, version 4.0
 - Microsoft Project for the Macintosh, version 4.0
---------------------------------------------------------------------
 
SYMPTOMS
========
 
In Microsoft Project, if you use a macro to add a subproject to a project,
and the subproject cannot be found, the Open dialog box appears even if you
used the Alerts method in the macro to turn off the display of alerts when
the macro is run.
 
CAUSE
=====
 
In a macro in Microsoft Project, the Alerts method does not suppress
the Open dialog box if a needed file cannot be found.
 
WORKAROUND
==========
 
To avoid having the Open dialog box appear when you add a subproject
to your project using a macro, use the Dir function to check to see
if the subproject file exists. The following macro example checks for
the existence of the subproject file, and adds it as a subproject if
it exists. If the subproject cannot be found, an error message is
displayed with this information.
 
   Sub Add_SubProject()
      ' Declare variables
      Dim SubProj As String, SubProjExists As String
      ' Define variable as subproject to be added
      SubProj = "c:\winproj\project3.mpp"
      ' Test for existence of subproject
      SubProjExists = Dir(SubProj)
      If SubProjExists <> "" Then
         ' If project file exists, add as subproject
         Projects(1).Tasks(1).Subproject = SubProj
      Else
         ' If project file cannot be found, display error message
         MsgBox "Can't find " & SubProj
      End If
   End Sub
 
Microsoft provides examples of Visual Basic procedures for illustration
only, without warranty either expressed or implied, including but not
limited to the implied warranties of merchantability and/or fitness for a
particular purpose. This Visual Basic procedure is provided 'as is' and
Microsoft does not guarantee that it can be used in all situations.
Microsoft does not support modifications of this procedure to suit customer
requirements for a particular purpose. Note that a line that is preceded by
an apostrophe introduces a comment in the code--comments are provided to
explain what the code is doing at a particular point in the procedure. Note
also that an underscore character (_) indicates that code continues from
one line to the next. You can type lines that contain this character as one
logical line or you can divide the lines of code and include the line-
continuation character.
 
STATUS
======
 
Microsoft has confirmed this to be a problem in the Microsoft products
listed at the beginning of this article. We are researching this problem
and will post new information here in the Microsoft Knowledge Base as it
becomes available.
 
MORE INFORMATION
================
 
Steps to Reproduce Behavior
---------------------------
 
1. In a new project, enter a task, T1.
 
2. From the Tools menu, choose Macros, and then choose the New button. In
   the Macro Name box, type "Add_SubProject" (without the quotation marks).
   Choose the Options button, and under Store Macro In, select the New
   project File option. Choose OK.
 
3. In the new module, enter the following macro:
 
      Sub Add_SubProject()
         Alerts False
         Projects(1).Tasks(1).Subproject = "project3.mpp"
      End Sub
 
4. From the View menu, choose Gantt Chart.
 
5. From the Tools menu, choose Macros. From the Macro Name list, select
   Add_SubProject and choose Run.
 
5. Run the macro
 
The Open dialog box appears with the title
 
   Can't find 'C:\WINPROJ\PROJECT3.MPP'
 
even though you used the Alerts method in the macro to turn off the display
of any messages.
 
REFERENCES
==========
 
For more information about the Alerts Method, choose the Search button in
the Visual Basic Reference and type:
 
   alerts
 
KBCategory: kbusage
KBSubcategory:
 
Additional reference words: 4.00
=============================================================================
Copyright Microsoft Corporation 1995.
