Sub SavetoHTML() ' Script to Export Project Data to HTML format file. ' Developed by Sreeram Kishore Chavali: August 2002 ' Information corporation: ckishore@informatica.com Dim rTasks As Task 'Will represent the Tasks On Error GoTo ErrorHandler Dim filename As String Position = InStr(1, ActiveProject.FullName, ".mpp", vbTextCompare) filename = Left(ActiveProject.FullName, Position) & "html" 'ActiveProject.Tasks Open filename For Output As #1 Print #1, "" Print #1, "" Print #1, " Tasks Report " Print #1, "

Tasks Report

" Print #1, "" Print #1, "" Taskcount = 0 ' Get all tasks in the project For Each rTasks In ActiveProject.Tasks i = 0 Taskcount = Taskcount + 1 spaces = "" While i < Len(rTasks.WBS) ' Add space to task name when its level increases spaces = spaces + "   " i = i + 1 Wend ' Set Bold font for Top Level Tasks If Len(rTasks.WBS) = 1 Then fontstr = "" Else fontstr = "" End If If rTasks.Notes <> "" Then noteshref = "   Task Notes " Else noteshref = "" End If If Len(rTasks.Name) > 75 Then Length = Len(rTasks.Name) - 75 task1 = Left(rTasks.Name, 75) & "-" task2 = Right(rTasks.Name, Length) Print #1, " " & "" & "" & "" & "" & "" & "" & "" Else task1 = rTasks.Name Print #1, " " & "" & "" & "" & "" & "" & "" & "" End If Next rTasks Print #1, "
Task Id Task Name Resource % Complete Start Date End Date
" & rTasks.ID & "" & fontstr & spaces & task1 & "
" & fontstr & spaces & task2 & noteshref & "
 " & rTasks.ResourceNames & "" & rTasks.PercentComplete & "" & Left(rTasks.Start, 7) & "" & Left(rTasks.Finish, 7) & "
" & rTasks.ID & "" & fontstr & spaces & rTasks.Name & noteshref & "  " & rTasks.ResourceNames & "" & rTasks.PercentComplete & "" & Left(rTasks.Start, 7) & "" & Left(rTasks.Finish, 7) & "
" Print #1, "
" For Each rTasks In ActiveProject.Tasks If rTasks.Notes <> "" Then noteshref = " Notes for Task id: " & rTasks.ID & " " Print #1, noteshref & rTasks.Notes & "

" Else noteshref = "" End If Next rTasks Print #1, "
" Print #1, "Report Generated on: " & Date Print #1, "" Close #1 MsgBox "Project Information has been Exported to file " & filename & " and contains " & Taskcount & " Tasks" Exit Sub ErrorHandler: Close #1 MsgBox Prompt:="Error # " & Err.Number & Chr(13) & Err.Description, _ Buttons:=vbExclamation, Title:="Error Found" End Sub