D
DebbiePartridge
Hi there
Wondering if anyone has any ideas what I'm doing wrong here?
I have a document with three sections, all of which contain a mix o
text in tables and outside of tables. I want to copy and paste variou
sections, sometimes one, sometimes one & three etc.
The code I have written works to a certain extent but, when pastin
text, loses the table format entirely (i.e. just pastes the text lin
after line) and changes the section breaks to page breaks.
The code is:
Sub Test3()
Dim WholeDocument As Range
Dim Bill As Range, Remuneration As Range, Narrative As Range
Set WholeDocument = Nothing
Set Bill = Nothing
Set Remuneration = Nothing
Set Narrative = Nothing
Set WholeDocument = ActiveDocument.Content
Selection.GoTo What:=wdGoToSection, Which:=wdGoToAbsolute, count:=1
ActiveDocument.Bookmarks("\section").Select
Set Bill = Selection.Range
Selection.GoTo What:=wdGoToSection, Which:=wdGoToAbsolute, count:=2
ActiveDocument.Bookmarks("\section").Select
Set Remuneration = Selection.Range
Selection.GoTo What:=wdGoToSection, Which:=wdGoToAbsolute, count:=3
ActiveDocument.Bookmarks("\section").Select
Set Narrative = Selection.Range
WholeDocument.Collapse Direction:=wdCollapseEnd
With WholeDocument
.InsertAfter (Bill)
.InsertAfter (Remuneration)
.InsertAfter (Narrative)
End With
End Sub
Any suggestions gratefully appreciated.
Many thanks
Debbi
Wondering if anyone has any ideas what I'm doing wrong here?
I have a document with three sections, all of which contain a mix o
text in tables and outside of tables. I want to copy and paste variou
sections, sometimes one, sometimes one & three etc.
The code I have written works to a certain extent but, when pastin
text, loses the table format entirely (i.e. just pastes the text lin
after line) and changes the section breaks to page breaks.
The code is:
Sub Test3()
Dim WholeDocument As Range
Dim Bill As Range, Remuneration As Range, Narrative As Range
Set WholeDocument = Nothing
Set Bill = Nothing
Set Remuneration = Nothing
Set Narrative = Nothing
Set WholeDocument = ActiveDocument.Content
Selection.GoTo What:=wdGoToSection, Which:=wdGoToAbsolute, count:=1
ActiveDocument.Bookmarks("\section").Select
Set Bill = Selection.Range
Selection.GoTo What:=wdGoToSection, Which:=wdGoToAbsolute, count:=2
ActiveDocument.Bookmarks("\section").Select
Set Remuneration = Selection.Range
Selection.GoTo What:=wdGoToSection, Which:=wdGoToAbsolute, count:=3
ActiveDocument.Bookmarks("\section").Select
Set Narrative = Selection.Range
WholeDocument.Collapse Direction:=wdCollapseEnd
With WholeDocument
.InsertAfter (Bill)
.InsertAfter (Remuneration)
.InsertAfter (Narrative)
End With
End Sub
Any suggestions gratefully appreciated.
Many thanks
Debbi