Select text and move to a header - how to do that in VBA
I want to select 3 lines of text (the 3 last lines in a document), then move this lines to the header of the document.
My macro does not work.
Here is the code.
Code:
Selection.EndKey Unit:=wdStory
Selection.MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Cut
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.MoveLeft Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Copy txt to hedaer in a word document
Quote:
Originally Posted by
macropod
There is nothing in your recorded code to paste the content from the clipboard into the header once you've accessed it. Insert:
Selection.Paste
before:
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Yes, there was no txt selected to the clipboard.
This works perfect now. Thank you very much for your kind help.
Ward