2014-03-31 76 views
0

我想用VBA创建一个包含带有文档评论页面的新文档。我只发现这个宏创建一个只列出评论的文档。我需要评论页面。如何修改它?提前致谢!如何使用页面和注释创建新的Word文档?

Sub PrintOnlyComments() 
Dim oThisDoc As Document 
Dim oThatDoc As Document 
Dim c As Comment 
Dim sTemp As String 
Dim iPage As Integer 

Set oThisDoc = ActiveDocument 
Set oThatDoc = Documents.Add 

Application.ScreenUpdating = False 
For Each c In oThisDoc.Comments 
    'Find page number of comment 
    oThisDoc.Select 
    c.Reference.Select 
    iPage = Selection.Information(wdActiveEndAdjustedPageNumber) 

    'Put info in new document 
    oThatDoc.Select 
    Selection.EndKey Unit:=wdStory 
    sTemp = "Page: " & iPage 
    Selection.TypeText Text:=sTemp 
    Selection.TypeParagraph 
    sTemp = "[" & c.Initial & c.Index & "] " & c.Range 
    Selection.TypeText Text:=sTemp 
    Selection.TypeParagraph 
    Next 
    Application.ScreenUpdating = True 
End Sub 
+0

也许你想要一个模板? '.docm'扩展我的意思是.http://filext.com/file-extension/DOCM – SerCrAsH

回答

0

我想通了。这是我的程序,如果有人感兴趣:

Sub PrintOnlyComments() 

Dim oThisDoc As Document 
Dim oThatDoc As Document 
Dim c As Comment 
Dim sTemp As String 
Dim iPage As Integer 
Dim iPage0 As Integer 


Set oThisDoc = ActiveDocument 
Set oThatDoc = Documents.Add 
iPage0 = 0 

Application.ScreenUpdating = False 
For Each c In oThisDoc.Comments 
    'Find page number of comment 
    oThisDoc.Select 
    c.Reference.Select 
    iPage = Selection.Information(wdActiveEndAdjustedPageNumber) 

    'paste the page to a new document 
    If iPage <> iPage0 Then 
    Selection.GoTo wdGoToPage, wdGoToAbsolute, iPage 
    Selection.Bookmarks("\Page").Range.Copy 
    oThatDoc.Activate 
    Selection.PageSetup.Orientation = wdOrientLandscape 
    Selection.EndKey 
    Selection.Paste 
    End If 

    iPage0 = iPage 
    Next 
    Application.ScreenUpdating = True 
End Sub