在 Visio 2016 中打印注释

在 Visio 2016 中打印注释

我不知道如何打印我在 Visio 图表中包含的注释。我找到了一个应该在 Visio 2013 中工作的宏。它确实创建了一个具有标题标题、审阅者、日期和注释的对象。但是,没有文本。
我猜这个宏基本正确,但缺少从 Visio 2013 到 Visio 2016 的某些变化。有人能帮忙吗?

谢谢

答案1

这是 Michael 脚本的修改版,有以下更改:列为数字和注释,而不是首字母、日期和注释。运行从 1 开始的计数器。对于每个带有注释的形状,将计数器 # 附加到形状的文本中,并在注释前加上计数器 #。这使得它像尾注一样工作,可以轻松找出哪个注释与哪个形状相匹配。请注意,它仍然只在活动的 visio 选项卡上工作。

Sub CommentsToPrint()
    Dim oPage As Visio.Page
    Dim oShape As Visio.Shape
    Dim oComments As Visio.Comment
    Dim sText As String
    Dim noteNum As Integer

    Set oPage = Visio.ActivePage
    sText = "Number" & vbTab & "Comment"

    'Loop through comments creating a string containing them all, and adding note numbers
    noteNum = 1
    For Each oComment In oPage.Comments
        oComment.AssociatedObject.Text = oComment.AssociatedObject.Text & " [" & noteNum & "]"
        sText = sText & vbCrLf & noteNum
        'sText = sText & vbCrLf & oComment.AuthorInitials
        'sText = sText & vbTab & oComment.EditDate
        sText = sText & vbTab & vbTab & oComment.Text
        noteNum = noteNum + 1
    Next oComment

    'Create a new shape with all the comments attached as visible text
    'Save the current value of autosize, create a rectangle using autosize=0     then restore autosize to its orignal value
    'The rectangle is created as the same size as the current page but immediately to the left of it
    Dim iAutoSize As Integer
    iAutoSize = oPage.AutoSize
    oPage.AutoSize = 0
    Set oShape = oPage.DrawRectangle(-oPage.PageSheet.Cells("PageWidth").ResultIU, 0, 0, oPage.PageSheet.Cells("PageHeight").ResultIU)
    oPage.AutoSize = iAutoSize
    'Set the text alignment for the rectangle to Top/Left
    oShape.Cells("Para.HorzAlign").Formula = "0"
    oShape.Cells("VerticalAlign").Formula = "0"
    'Give it a name and add the comments to it
    oShape.Name = "Review Comments"
    oShape.Text = sText
End Sub

答案2

这个问题问了好久了,但今天我遇到了这个问题,所以我草草写了一个快速而粗糙的脚本,在当前页面的左侧创建一个矩形(类似于我见过的其他解决方案),然后将活动页面的所有注释附加到新对象。我认为问题在于 Visio 2016 中的注释模型与以前完全不同。

如果这对任何人都有帮助,请随意使用它

'This is in no way comprehensive and is not intended to be production quality
'It does what it does
'Michael Cameron July 2018

Public Sub ShowComments()
Dim oPage As Visio.Page
Dim oShape As Visio.Shape
Dim oComments As Visio.Comment
Dim sText As String

Set oPage = Visio.ActivePage
sText = "Initials" & vbTab & "Date" & vbTab & "Comment"

'Loop through comments creating a string containing them all
For Each oComment In oPage.Comments
    sText = sText & vbCrLf & oComment.AuthorInitials
    sText = sText & vbTab & oComment.EditDate
    sText = sText & vbTab & oComment.Text
Next oComment

'Create a new shape with all the comments attached as visible text
'Save the current value of autosize, create a rectangle using autosize=0     then restore autosize to its orignal value
'The rectangle is created as the same size as the current page but immediately to the left of it
Dim iAutoSize As Integer
iAutoSize = oPage.AutoSize
oPage.AutoSize = 0
Set oShape = oPage.DrawRectangle(-oPage.PageSheet.Cells("PageWidth").ResultIU, 0, 0, oPage.PageSheet.Cells("PageHeight").ResultIU)
oPage.AutoSize = iAutoSize
'Set the text alignment for the rectangle to Top/Left
oShape.Cells("Para.HorzAlign").Formula = "0"
oShape.Cells("VerticalAlign").Formula = "0"
'Give it a name and add the comments to it
oShape.Name = "Review Comments"
oShape.Text = sText
End Sub

相关内容