File: pjxml_using.htm

package info (click to toggle)
office2003-schemas 1.0%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, forky, sid, trixie
  • size: 42,304 kB
  • sloc: javascript: 2,429; makefile: 29
file content (191 lines) | stat: -rw-r--r-- 8,496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<html dir="ltr"><head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="assetid" CONTENT="HV01051041"><META NAME="lcid" CONTENT="1033"><title>Using XML Files with Microsoft Office Project 2003</title><link rel="stylesheet" type="text/css" href="office10.css"><script type="text/javascript" language="Javascript" src="ExpCollapse.js"></script><script type="text/javascript" language="JavaScript" src="inline.js"></script></head><body><p id="ExpandAllLine" class="ExpFav"><a href="#" onclick="ExpandAll()" onkeypress="ExpandAll()" class="DropDown"><img id="picHeader" border="0" src="expandtri.gif" alt="Show All"><span id="ExpandAll">Show All</span></a></p><h1>Using XML Files with Microsoft Office Project 2003</h1><p>Project files may be saved in XML format by clicking <b class="ui">Save As</b> on the <b class="ui">File</b> menu, or saved 
		to an XML file or DOM document by using Visual Basic for Applications (VBA). 
		In Project, you can also directly open an XML file that is valid, according to the Project XML Schema. You can also open a 
		valid XML file, DOM (Document Object Model) document, or SOAP string by using VBA.</p><p>The following are code samples for using XML with VBA in Project. 
		To use the XML DOM, set a reference in the Visual Basic Editor of Project to Microsoft XML.  
		It is recommended that you use 
		<i>Microsoft XML, v4 </i> (normally installed in <i>C:\WINDOWS\system32\msxml4.dll)</i>, 
		or <i>Microsoft XML, v5 </i> (installed with Office&nbsp;2003 in 
		<i>C:\Program Files\Common Files\Microsoft Shared\OFFICE11\msxml5.dll</i>. 
		In either case, the library namespace is <i>MSXML2</i>.</p><p>For recommendations on how to create a valid XML template and how to append XML data to an existing project, see 
	<a href="pjxml_overview.htm" id="HV01051036" lcid=" ">Overview of XML for Project</a>.
	</p>
			<p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show">Open a project from an XML DOM document</a></p>
			<div id="ExpCol" class="collapsed" border="0">
				<p>The following code sample shows how to transform a DOM document into a Project XML DOM document and 
		open it in Project. This method is useful when transforming an XML document containing project data 
		that does not conform to the Project Data Interchange Schema.</p>
				<pre><code>Public Sub fileopen_xmldom(xml As String)

    On Error GoTo err_fileopen_xmldom
    
    Dim app As New MSProject.Application
    Dim xmlDom, xslDom, projDom, xslFileName As String
    
    'Load the XML string parameter into a DOM document
    Set xmlDom = CreateObject("MSXML2.DOMDocument")
    xmlDom.async = False
    xmlDom.loadXML xml
    
    'Specify an XSL template file name
    xslFileName = "C:\project\xml\project.xsl"
    
    'Load the XSL template into a DOM document
    Set xslDom = CreateObject("MSXML2.DOMDocument")
    xslDom.async = False
    xslDom.Load xslFileName
    
    'Transform the XML input into a project XML document
    Set projDom = CreateObject("MSXML2.DOMDocument")
    projDom.Load xmlDom.transformNode(xslDom)
    
    'Open a project from the XML DOM document
    app.FileOpen FormatID:="MSProject.XMLDOM", XMLName:=projDom

exit_fileopen_xmldom:
    Exit Sub
    
err_fileopen_xmldom:
    MsgBox "error: " &amp; Err.Description
    GoTo exit_fileopen_xmldom
End Sub

Public Sub Fileopen_xmldom_test()
    Dim xmlDom, XMLfileName As String
    XMLfileName = "C:\proj10\xml\xmldemo\x1.xml"
    Set xmlDom = CreateObject("MSXML2.DOMdocument")
    xmlDom.async = False
    xmlDom.Load XMLfileName
    fileopen_xmldom (xmlDom.xml)
End Sub</code>
				</pre>
			</div>
		
			<p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show">Open a project from an XML file</a></p>
			<div id="ExpCol" class="collapsed" border="0">
		The following code sample shows how to use a Project XML document file created by a third party 
		application to create a project. This sample assumes that the file created by 
		a third party application already contains valid XML that conforms to the Project XML Schema.
 <pre><code>Public Sub fileopen_xmlfile()

    On Error GoTo err_fileopen_xmlfile
    
    Dim app As New MSProject.Application, xmlFile As String
    
    'Specify a Microsoft Project XML file name
    xmlFile = "C:\project\xml\someProject.xml"
    
    'Open a project from the XML file
    app.FileOpen Name:=xmlFile, FormatID:="MSProject.XML"

exit_fileopen_xmlfile:
    Exit Sub
    
err_fileopen_xmlfile:
    MsgBox "error: " &amp; Err.Description
    GoTo exit_fileopen_xmlfile

End Sub</code>
				</pre>
			</div>
		
			<p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show">Open a project from a string containing XML</a></p>
			<div id="ExpCol" class="collapsed" border="0">
				<p>The following code sample shows how to use Simple Object Access Protocol (SOAP) to call a Web page 
		that returns an XML string that conforms to the Project XML Schema.</p>
				<pre><code>Public Sub openxml_xmlstring(xmlRequest As String)

    On Error GoTo err_openxml_xmlstring
    
    Dim app As New MSProject.Application
    Dim XMLHttp As XMLHttp
    Dim xmlResponse As String, URL As String
    
    'Specify the web page to call
    URL = "http://myserver/getProjectXML.asp"
    
    'Create the SOAP client and call the page
    Set XMLHttp = New XMLHttp
    XMLHttp.Open "POST", URL, False
    XMLHttp.send xmlRequest
    xmlResponse = XMLHttp.responseXML.xml
    
    'Open a project from the response string
    app.OpenXML xmlResponse

exit_openxml_xmlstring:
    Exit Sub
    
err_openxml_xmlstring:
    MsgBox "error: " &amp; Err.Description
    GoTo exit_openxml_xmlstring

End Sub</code>
				</pre>
			</div>
		
			<p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show">Save a project to an XML DOM document</a></p>
			<div id="ExpCol" class="collapsed" border="0">
		The following code sample shows how to save a project as an XML DOM document 
		that conforms to the Project XML Schema. This allows developers to use the properties and methods of 
		the DOM to manipulate and extract project data.
 <pre><code>Public Sub filesaveas_xmldom()

    On Error GoTo err_filesaveas_xmldom
    
    Dim app As New MSProject.Application
    Dim doc
    
    'Create an XML DOM document
    Set doc = CreateObject("MSXML2.DOMDocument")
    
    'Save the project to the DOM document
    app.FileSaveAs FormatID:="MSProject.XMLDOM", XMLName:=doc

exit_filesaveas_xmldom:
    Exit Sub
    
err_filesaveas_xmldom:
    MsgBox "error: " &amp; Err.Description
    GoTo exit_filesaveas_xmldom

End Sub</code>
				</pre>
			</div>
		
			<p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show">Save a project file as an XML file</a></p>
			<div id="ExpCol" class="collapsed" border="0">
		The following code sample shows how to save Project data as an XML file that conforms to the 
		Project XML Schema. This code sample can be used to drop a Project XML document to a file share to be 
		picked up and used later by an asynchronous process.
 <pre><code>Public Sub filesaveas_xmlfile()

    On Error GoTo err_filesaveas_xmlfile 
    
    Dim app As New MSProject.Application, xmlFile As String
    
    'Specify a Microsoft Project XML file name
    xmlFile = "C:\path to location\fileName.xml"
    
    'Open a project from the XML file
    app.FileSaveAs Name:=xmlFile, FormatID:="MSProject.XML"

exit_filesaveas_xmlfile:
    Exit Sub
    
err_filesaveas_xmlfile:
    MsgBox "error: " &amp; Err.Description
    GoTo exit_filesaveas_xmlfile

End Sub</code>
				</pre>
			</div>
		<center><a href="XMLSchemaCopyright_HV01147162.htm">&copy;2003-2004 Microsoft Corporation. All rights reserved.</a>  

Permission to copy, display and distribute this document is available at: <a 

href="http://r.office.microsoft.com/r/rlidAWSContentRedir?AssetID=XT010988631033&amp;CTT=11&amp;Origin=HV011232471033" 

target="_new">http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp</a></center></body></html>