2014-03-31 113 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