Prevent Open Resource Pool Dialogue box when opening MPP Project File using VBA

mond007

New Member
Joined
Oct 9, 2008
Messages
34
Hi </SPAN></SPAN>

I have some code that I am using to Open a Microsoft Project file but despite all efforts I have been unable to prevent the opening dialogue box from appearing or auto answering it.</SPAN>

i.e. "Open resource pool read-only allowing others to work on projects connected to the pool"</SPAN></SPAN>
I have tried "Application.EnableEvents = False", "Application.DisplayAlaerts = False" and .FileOpenEx all to no avail.</SPAN></SPAN>

I would appreciate some help. Thanks in advance.</SPAN></SPAN>

Code:
    Public Sub extract_data()</SPAN></SPAN>
   
    Dim appProj As MSProject.Application</SPAN></SPAN>
    Dim aProg As MSProject.Project</SPAN></SPAN>
    Dim app</SPAN></SPAN>
    Dim mppApp As MSProject.Application</SPAN></SPAN>
    Dim Tasks As Tasks</SPAN></SPAN>
    Dim mpp_file_name As String</SPAN></SPAN>
    Dim j As Integer</SPAN></SPAN>
       
        Set destination_ws = ThisWorkbook.Worksheets("Imported Vehicles")</SPAN></SPAN>
        destination_ws.Cells.Clear</SPAN></SPAN>
       
        file_location = ThisWorkbook.Worksheets("Control Panel").Range("F19").Value</SPAN></SPAN>
        file_name = ThisWorkbook.Worksheets("Control Panel").Range("F20").Value</SPAN></SPAN>
        file_location_and_name = file_location & file_name</SPAN></SPAN>
       
        Set appProj = CreateObject("Msproject.Application")</SPAN></SPAN>
          
        '---------------------------------------------------------------------</SPAN></SPAN>
        'Set appProj = GetObject(, "MSProject.Application")</SPAN></SPAN>
        'If IsEmpty(appProj) Then Set appProj = CreateObject("MSProject.Application")</SPAN></SPAN>
        'appProj.FileOpenEx Name:=file_location_and_name, ReadOnly:=True</SPAN></SPAN>
        '---------------------------------------------------------------------</SPAN></SPAN>
       
        Application.EnableEvents = True</SPAN></SPAN>
        Set mppApp = CreateObject("msproject.application")</SPAN></SPAN>
       
        mppApp.DisplayAlerts = False</SPAN></SPAN>
        mppApp.FileOpen Name:=file_location_and_name, ReadOnly:=True ' Opens file as Read Only</SPAN></SPAN>
       
        mppApp.DisplayAlerts = False</SPAN></SPAN>
        Application.EnableEvents = True</SPAN></SPAN>
       
        '--------------------------- WAIT FOR IE TO CATCH UP --------------------------</SPAN></SPAN>
        newHour = Hour(Now())</SPAN></SPAN>
        newMinute = Minute(Now())</SPAN></SPAN>
        newSecond = Second(Now()) + 3</SPAN></SPAN>
        waitTime = TimeSerial(newHour, newMinute, newSecond)</SPAN></SPAN>
        Application.Wait waitTime</SPAN></SPAN>
        '------------------------------------------------------------------------------</SPAN></SPAN>
       
        Set aProg = mppApp.ActiveProject</SPAN></SPAN>
        'aProg.Visible = True</SPAN></SPAN>
       
        Application.SendKeys "{TAB}"   'Enter to OK</SPAN></SPAN>
        Application.SendKeys "^~"   'Enter yes to OK</SPAN></SPAN>
       
        'COPY DATA ACROSS code</SPAN></SPAN>
 
        Set mpApp = Nothing</SPAN></SPAN>
   
        DoEvents</SPAN></SPAN>
   
        MsgBox "Data from MS Project File Copied", vbInformation</SPAN></SPAN>
   
    End Sub
</SPAN></SPAN>
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,214,653
Messages
6,120,752
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top