F
Frank Carius \(MVP\)
Project 2007 on Vista as standalone app (no Project Server/Database behind)
I tried to generate a output of a MPP File intoa DOC-File. like that
every task is a Headline in Word
the Notes of that task and some other details are added as text.
So after playing with reports etc i found only three ways.
- Save file al XML and build a XSLT to transfer ist in HTML and let Word
import that.
- VBA Macro to write HTML
- VBA Macro using Word for adding that (or the clipboard)
I choose 2.
Thats what i have done so far
Sub Export2HTML()
Dim item As Task
Dim strReport, strNotes As String
Dim vbvt: vbvt = Chr(11) ' VerticalTab
strReport = "<html>"
For Each item In ActiveProject.Tasks
If Not item Is Nothing Then
strNotes = "<p>" & item.Notes & "</p>"
strNotes = Replace(strNotes, vbCr, "</p><p>" & vbCrLf)
strNotes = Replace(strNotes, vbvt, "<br>" & vbCrLf)
strReport = strReport & "<h" & item.OutlineLevel + 1 & ">" &
item.Name & "</h" & item.OutlineLevel + 1 & ">" & vbCrLf _
& "<p><table width=""400px"" border=""1""><tr>"
_
& "<td>Tasknumber:</td><td>" & item.ID &
"</td>" & vbCrLf _
& "</tr><tr>" & vbCrLf _
& "<td>Predecessors:</td><td>" &
item.Predecessors & "</td>" & vbCrLf _
& "</tr><tr>" & vbCrLf _
& "<td>Duration (min):</td><td>" &
item.Duration & "</td>" & vbCrLf _
& "</tr><tr>" & vbCrLf _
& "<td>Notes:</td><td>" & strNotes & "</td>"
& vbCrLf _
& "</tr></table>" & vbCrLf
End If
Next
strReport = strReport + "</html>"
MyFile = "c:\users\fcarius\prjreport.htm"
fnum = FreeFile()
Open MyFile For Output As fnum
Write #fnum, strReport
Close #fnum
End Sub
Yea it works nice. BUT. the "notes"-String is only "TEXT".
Is there any way to get the "notes" of an task using VBA ?
You can format text in the project notes (unnumbered lists etc)
Any you can Cut copy paste even more formatted data.
But all i get with a "strNotes = item.notes" is a "plain text repesentation
with some "CR" and some "VerticalTabs"
Any idea to get the RTF/HTML or anything else content ?
I tried to generate a output of a MPP File intoa DOC-File. like that
every task is a Headline in Word
the Notes of that task and some other details are added as text.
So after playing with reports etc i found only three ways.
- Save file al XML and build a XSLT to transfer ist in HTML and let Word
import that.
- VBA Macro to write HTML
- VBA Macro using Word for adding that (or the clipboard)
I choose 2.
Thats what i have done so far
Sub Export2HTML()
Dim item As Task
Dim strReport, strNotes As String
Dim vbvt: vbvt = Chr(11) ' VerticalTab
strReport = "<html>"
For Each item In ActiveProject.Tasks
If Not item Is Nothing Then
strNotes = "<p>" & item.Notes & "</p>"
strNotes = Replace(strNotes, vbCr, "</p><p>" & vbCrLf)
strNotes = Replace(strNotes, vbvt, "<br>" & vbCrLf)
strReport = strReport & "<h" & item.OutlineLevel + 1 & ">" &
item.Name & "</h" & item.OutlineLevel + 1 & ">" & vbCrLf _
& "<p><table width=""400px"" border=""1""><tr>"
_
& "<td>Tasknumber:</td><td>" & item.ID &
"</td>" & vbCrLf _
& "</tr><tr>" & vbCrLf _
& "<td>Predecessors:</td><td>" &
item.Predecessors & "</td>" & vbCrLf _
& "</tr><tr>" & vbCrLf _
& "<td>Duration (min):</td><td>" &
item.Duration & "</td>" & vbCrLf _
& "</tr><tr>" & vbCrLf _
& "<td>Notes:</td><td>" & strNotes & "</td>"
& vbCrLf _
& "</tr></table>" & vbCrLf
End If
Next
strReport = strReport + "</html>"
MyFile = "c:\users\fcarius\prjreport.htm"
fnum = FreeFile()
Open MyFile For Output As fnum
Write #fnum, strReport
Close #fnum
End Sub
Yea it works nice. BUT. the "notes"-String is only "TEXT".
Is there any way to get the "notes" of an task using VBA ?
You can format text in the project notes (unnumbered lists etc)
Any you can Cut copy paste even more formatted data.
But all i get with a "strNotes = item.notes" is a "plain text repesentation
with some "CR" and some "VerticalTabs"
Any idea to get the RTF/HTML or anything else content ?