Current open MS Project saved as XML element

Hello,

I am currently trying to develop a way to save the current Project into an XML DOM object element. This is then sent over a SOAP object to a Webservice I have running.

I have an implementation that uses the SaveAs function to save into an XML and passing that directly into the SOAP, but I've run into performance issues and would like to send the file directly (binary) and have the Webservice deal with it then.

Heres what I have so far that converts the .mpp file into .xml and pipes it over a soap object. I need to imbed the .mpp file in a blank .xml file as a binary attachment (no conversion), the conversion will happen later on the Webserver.

 


Sub ExportXML()



Dim fResult

Dim app As New MSProject.Application
Dim XMLdoc As New MSXML2.DOMDocument50
Dim objSClient As MSSOAPLib.SoapClient

Dim StringXMLdoc As String

XMLdoc.async = False

app.FileSaveAs FormatID:="MSProject.XMLDOM", XMLName:=XMLdoc

Set objSClient = New SoapClient

Call objSClient.MSSoapInit("http://localhost/mppsoap/Service1.asmx WSDL")

MsgBox ("Created Soap object and connected to service")

' Call the web service
StringXMLdoc = XMLdoc.xml


Set XMLdoc = Nothing

' The webservice has a function called Import with int, string parameters

Set fResult = objSClient.Import(25, StringXMLdoc)
Set objSClient = Nothing

MsgBox (fResult)
 
End Sub

 


 

I'm stuck using the SaveAs function, I would use casting but I'm not familar with that in VBA.

 

Thanks!



Answer this question

Current open MS Project saved as XML element

  • Cogz

    I guess my question has to do more with the documentation of the SaveAs function. From web examples I found how to save the current project into a xml string, but nothing more. All I need to do is save the project(in binary form) into an object within VBA.

    app.FileSaveAs FormatID:="MSProject.XMLDOM", XMLName:=XMLdoc

    That i get, loading the msproject interop into Visual Studio and exploring the object, i dont see any reference to FormatID and I really dont understand how you know what object type to save as.

    What I would like is something like:

    var ProjDoc
    app.FileSaveAs FormatID:="MSProject.MSProjectBin", Name:=ProjDoc


    ....


    then pass that into an xml and send that to a webservice.



    On a side note, the On_BeforeSave function cannot call the FileSaveAs for some reason. It keeps giving me an error regarding _FileSaveAs something. Maybe this on_beforesave would make this scenario recursive

  • Balthazarkitty

    Hi,

    Here's some additional information from our support team:

    We can find the definition of the function, < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    http://msdn.microsoft.com/library/en-us/pjsdk/html/pjmthSaveAs_HV43008564.asp frame=true

     

    If a binary project file wants to be saved, we can write like:

    app.FileSaveAs FormatID:= "MSProject.mpp", Name:=ProjDoc

     

    The other question, you can add a switch variable in your class. Before filesaveas in code is called, the switch is turned on. And it is closed, when filesaveas finished.

    And the function will be called when the switch is off.

    This is just a suggestion for you to try out.

    -brenda (ISV Buddy Team)



  • WhyNadeem

    Per the support engineer...

    This issue is related to a send a file to a web services. To transfer a file to a web service, we can use the CDATA session of the XML.< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    We can construct a XML string with the binary file, and save it as an xml file. Then we can commit this xml string as a parameter to the web service.

    As you are pending on the saveas function, could you tell me what is the error of the issue

    -brenda (ISV Buddy Team)

     



  • Current open MS Project saved as XML element