I have project files with multiple tasks where each task contain text or MS Word notes. Retrieving text notes is quite easy, but no information is available for getting MS Word documents from the task notes.
Hi Mark,
- What is the Notes structure
- Whether Notes contain a single embedded object or a list of objects
- Embedded objects are of same type or mixture of text and objects, etc.
Hi Kashif,
Hi Mark,
ProjectReader reader = new
ProjectReader();<o:p></o:p>
Project project = reader.Read("Project1.mpp");
Task task = project.GetTaskById(1);
File.WriteAllText("Notes.rtf", task.NotesRTF);
Document doc = null;
using (MemoryStream stream = new MemoryStream())
using (StreamWriter streamWriter = new StreamWriter(stream))
{
streamWriter.Write(task.NotesRTF);
doc = new Document(stream);
}
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
foreach (Shape shape in shapes)
{
if (shape.OleFormat != null)
{
if (!shape.OleFormat.IsLink)
{
//Extract OLE Word object
if (shape.OleFormat.ProgId == "Word.Document.12")
{
MemoryStream stream = new MemoryStream();
shape.OleFormat.Save(stream);
Document newDoc = new Document(stream);
newDoc.Save("Embedded doc.doc");
}
}
}
}