Print comments from visio drawing

C

Chris [Visio MVP]

You probably want to print them right on the page, but I'm not sure how to
do that.

The following VBA macro code will allow you to extract the comments from all
pages of a Visio document to a file called DocumentComments.txt, that will
be in the same directory as the Visio file.

If you know how to run VBA macros, this may be of use to you.


--
Hope this helps,

Chris Roth
Visio MVP


----------------------------------

Sub DumpComments()

Dim pg As Visio.Page
Dim i As Integer
Dim result As String

For Each pg In ThisDocument.Pages

If result <> vbNullString Then result = result & vbCrLf

result = result & "Comments for Page: " & pg.Name & vbCrLf
result = result & "--------------------" & vbCrLf

For i = 0 To pg.PageSheet.RowCount(Visio.visSectionAnnotation) - 1
Debug.Print m_getCommentBlock(pg, i)
result = result & m_getCommentBlock(pg, i) & vbCrLf
Next i

Next

Debug.Print result

'// Write the file:
Call m_writeFile(result)

End Sub

Private Function m_getCommentBlock(pg As Visio.Page, iRow As Integer) As
String

Dim result As String

result = "Date: " & m_getCommentItem(pg, iRow,
Visio.VisCellIndices.visAnnotationDate)
result = result & "By: " & m_getCommentItem(pg, iRow,
Visio.VisCellIndices.visAnnotationReviewerID) & vbCrLf
result = result & "Comment: " & m_getCommentItem(pg, iRow,
Visio.VisCellIndices.visAnnotationComment) & vbCrLf

m_getCommentBlock = result

End Function

Private Function m_getCommentItem(pg As Visio.Page, iRow As Integer,
visCellIndex As Integer) As String


m_getCommentItem = pg.PageSheet.CellsSRC(Visio.visSectionAnnotation, _
iRow, _
visCellIndex).ResultStr(Visio.VisUnitCodes.visNoCast)

End Function


Private Sub m_writeFile(sBlock As String)

'// Write the text file:
Dim fso As New FileSystemObject
Dim f As TextStream
Set f = fso_OpenTextFile(ThisDocument.Path & "DocumentComments.txt",
ForWriting, True, TristateUseDefault)
Call f.Write(sBlock)
f.Close

End Sub
 

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