none
OpenXML versus FileOpen RRS feed

  • Question

  • Hello,

    I use MSP2003 via OLE Automation in my application. Now i try to convert it into MSP2010. I was transforming data through ODBC for MSP2003. It does not work in 2010 - I decide to use XML.

    I generade XML file and try to open it in MSP2010 through OLE Automation. There are two commands:

    a) function FileOpen(Name: OleVariant; ReadOnly: OleVariant; Merge: OleVariant;
                          TaskInformation: OleVariant; Table: OleVariant; Sheet: OleVariant;
                          NoAuto: OleVariant; UserID: OleVariant; DatabasePassWord: OleVariant;
                          FormatID: OleVariant; Map: OleVariant; openPool: PjPoolOpen;
                          Password: OleVariant; WriteResPassword: OleVariant;
                          IgnoreReadOnlyRecommended: OleVariant; XMLName: OleVariant): WordBool;

    it works correctly. XML file is loaded into MSP2010. But htere is problem that it is not standart open. It looks more like import. There is problematic popup window in which i am asked for selecting if it is imported as new project, added to active project or merged with active project. I do not want this question, it is new project.

    b) function OpenXML(const XML: WideString): SYSINT;

    It works correctly and withought popup window question. But only for XML files generated from MSP. It announces error if I make my own XML file with some parts are missing (for example TimephasedData section). These files withought missing some parts are openable through FileOpen.

    Is any way how can I use FileOpen for opening XML file withought question window?

    Dan

    Monday, March 26, 2012 12:43 PM

All replies

  • It looks that I was not enought specific. When I use this command:

    FileOpen('c:\file.xml',False,pjDoNotMerge,True,'','',False,'','','MSProject.XML','',pjPromptPool,'','',False,null)

    I succesfully open xml file in MSP2010. But there is problematic dialog during opening in which i must select if i want import data as new project, add to active project or merge with active project. And I do not want to solve this question by dialog during opening. Is any way how to solve it withought dialog window?

    Tuesday, March 27, 2012 7:32 AM
  • I don't have a specific answer to you, but I always start from a saved .xml file of a 1 task, 1 resource, 1 assignment project and remove what I don't want and open.

    I get what I need done using VBA and then I convert to vb or c#.

    hope this helps.I recorded a macro opening and creating a new project and teh Merge parameter is the one you need. If you're not using vb, I strongly recommend upgrading to C# 2010 as it has named and optional parameters which make for much quicker development and much easier to understand and maintain code.


    Rod Gill

    The one and only Project VBA Book Rod Gill Project Management

    Tuesday, March 27, 2012 7:43 AM
    Moderator
  • It looks that problem is somewhere in OLE communication. Or OLE function is different than function used directly (in visual basic script).

    When i write macro in visual basic

    FileOpen Name:="C:\pokus.xml", ReadOnly:=False, Merge:=pjDoNotMerge, TaskInformation:=False, Table:="", Sheet:="", NoAuto:=False, UserId:="", DatabasePassWord:="", FormatID:="MSProject.xml", Map:="", OpenPool:=pjPromptPool, Password:="", WriteResPassword:="", IgnoreReadOnlyRecommended:=False, XMLName:=Null

    it works correctly and there is no "import" dialog.

    When I use OLE Automation in Delphi 2007, use MSP2010 typed library, use interface DIID__MSProject  (ClassID='{36D27C48-A1E8-11D3-BA55-00C04F72F325}') and function

    function FileOpen(Name: OleVariant; ReadOnly: OleVariant; Merge: OleVariant;
                          TaskInformation: OleVariant; Table: OleVariant; Sheet: OleVariant;
                          NoAuto: OleVariant; UserID: OleVariant; DatabasePassWord: OleVariant;
                          FormatID: OleVariant; Map: OleVariant; openPool: PjPoolOpen;
                          Password: OleVariant; WriteResPassword: OleVariant;
                          IgnoreReadOnlyRecommended: OleVariant; XMLName: OleVariant): WordBool; dispid 102;

    third parameter is Merge. My command in delphi is

    DefaultInterface.FileOpen('c:\pokus.xml',False,pjDoNotMerge,True,'','',False,'','','MSProject.XML','',pjPromptPool,'','',False,null);

    this works near the same as in visual basic. With only one different. Import dialog occures:

    http://xfojtik.sweb.cz/ImportDialog.jpg

    Tuesday, March 27, 2012 12:04 PM
  • I make small demonstation exe which illustrate problem with FileOpen. There is exe which try to open file c:\pokus.xml. Pokus.xml is small XML file generated in MSP2010. There is problematic "import" dialog during opening xml file. In "resources" directory are all delphi resources of this exe. Everything needful is in procedure TForm1.Button1Click.

    http://xfojtik.sweb.cz/fin.zip

    Wednesday, March 28, 2012 10:50 AM