How to get formatted fcontent from item.notes

  • Thread starter Frank Carius \(MVP\)
  • Start date
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 ?
 
R

Rod Gill

Hi Frank,

Unfortunately a quick search of the Object Browser confirms that there
isn't. Rtf format can be retrieved when a project is saved in a database,
but this option isn't available any more in Project 2007.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
F

Frank Carius \(MVP\)

Rod Gill said:
Unfortunately a quick search of the Object Browser confirms that there
isn't. Rtf format can be retrieved when a project is saved in a database,
but this option isn't available any more in Project 2007.


Thanks for that quick answer (even if it is not, what i hoped :-/)
So i'll stay with that restriction and add HTML-Code directly in the Text
Property. I think there is no"single users Project Server" like a SQLExpress
:) . just kidding :)

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top