none
VBA Open Project file in specific view

    Question

  • Is there a way to open an MSProject file in a specific view via VBA?  I am opening the file in the backgroup to loop through the tasks from Excel and the file is often saved in a view that has a date range filter.  I don't want users to be prompted for a date range since using a

    For Each tsk in proj.Task

     ignores the filter anyway.

    Thanks!

    Thursday, February 16, 2012 2:36 PM

Answers

All replies

  • You could try :

    Application.DisplayAlerts=False

    Before opening the file and reset to True after opening. If that still prompts for a date range then you could add code to reset the filter to "All Tasks" on the Close event.


    Rod Gill

    The one and only Project VBA Book Rod Gill Project Management

    Thursday, February 16, 2012 7:21 PM
    Moderator
  • That was my first thought, but the file seems to ignore that.

    The users apply a specific (custom) view when they use the file (similar to gantt view but has custom filter that includes prompting for a date range so it only shows items that open and close during the date range).  This is the view that they always use and save the file this way.  So, when I go to open the file, that is the way that it tries to open and it prompts me for a date range.

    The prompt comes when you do a app.FileOpen command.  It does not seem to be affected by doing an app.DisplayAlerts = False prior to opening the file. 

    Since the prompt comes up on open, I cannot just switch the applied view after opening because the prompt has already occured.  The only way that I can think of to avoid the prompt is to open the file in a specific view (say: Gantt view with no filter applied)

    Tuesday, February 21, 2012 12:08 AM
  • I think you're out of luck then. Another alternative is to have a macro the user runs to export data you are interested in to either Excel or SQL Server. Your macro can then read the data it needs from the Excel file or SQL Server. Shame Project 2003's beautiful read from .mpp using OLEDB no longer exists!

    Rod Gill

    The one and only Project VBA Book Rod Gill Project Management

    Tuesday, February 21, 2012 12:35 AM
    Moderator