Hello,
I have a macro that copies a body of text and places it into a new section at the "bottom" of the current document. (See SAMPLE CODE below.)
The macro is connected to a Macro Button that is part of a locked MS Word 2010 macro enabled template.
I am attempting to create a similar macro that will copy a body of text and place into a new section "directly below" the section that contains the macro button. Can I modify the existing macro to do that?
I assume I need a way to have the macro set the insertion point below the macro button so that the page will paste in the proper location.
Any assistance will be appreciated.
Thanks
------------------------
SAMPLE CODE
Sub CreateNewProgressNotePage()
'Code below unlocks the original document
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
'Code below selects the text between two Bookmarks in the document
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
oRng.Start = ActiveDocument.Bookmarks("P_Start").Range.End
oRng.End = ActiveDocument.Bookmarks("P_End").Range.Start
oRng.Select
' Code below will Unhide the selection
With Selection.Font
.Hidden = False
End With
' Code below copys the selected text
Selection.Copy
' Code below will Hide the selection again
With Selection.Font
.Hidden = True
End With
' Code below navigates to the end of the document and creates a section break
Selection.EndKey Unit:=wdStory
Selection.InsertBreak Type:=wdSectionBreakNextPage
' Code below pastes what was copied earlier
Selection.PasteAndFormat (wdFormatOriginalFormatting)
' Code below relocks the original document
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
' Code below navigates to the End of the Document
Selection.EndKey Unit:=wdStory
Selection.MoveUp Unit:=wdScreen, Count:=1
End Sub