PDA

View Full Version : Solved: Page formatting from a point onwards in a document



SOS
06-11-2008, 06:13 AM
Hi folks,

Working with code which adds a new doc via a template and then inserts another file and I want to change the margins (but just of the inserted file). I have the code:



Sub Add_Doc()
Documents.Add Template:= _
"C:\Assessment.dot", NewTemplate:=False, DocumentType:=0
With Selection
.EndKey Unit:=wdStory
.InsertBreak Type:=wdPageBreak
End With
With ActiveDocument.Range(Start:=Selection.Start, End:=ActiveDocument. _
Content.End).PageSetup
.TopMargin = CentimetersToPoints(1.3)
.BottomMargin = CentimetersToPoints(1.3)
.LeftMargin = CentimetersToPoints(1.5)
.RightMargin = CentimetersToPoints(1.5)
End With
Selection.InsertFile FileName:="SSA Form.doc", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
End Sub



which SHOULD set margins from the PageBreak onwards but instead it is setting the margins for the whole document.

Can anyone point me in the right direction please?

As always any help is much appreciated

Seamus

SOS
06-11-2008, 06:55 AM
I managed to work it out by changing the code slightly. It is now:



Sub Add_Doc()
Documents.Add Template:= _
"C:\Assessment.dot", NewTemplate:=False, DocumentType:=0
With Selection
.EndKey Unit:=wdStory
.InsertBreak Type:=wdSectionBreakNextPage
End With
With ActiveDocument.Range(Start:=Selection.Start, End:=ActiveDocument. _
Content.End).PageSetup
.TopMargin = CentimetersToPoints(1.3)
.BottomMargin = CentimetersToPoints(1.3)
.LeftMargin = CentimetersToPoints(1.5)
.RightMargin = CentimetersToPoints(1.5)
End With
Selection.InsertFile FileName:="SSA Form.doc", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
End Sub



and it works

Thanks

Seamus

fumei
06-11-2008, 10:05 AM
Thanks for posting your own solution. Please mark the thread as Solved.

SOS
06-11-2008, 02:38 PM
fumei,

I thought I did that when I posted Solved in the title bar when I replied. Is there somewhere else I should be marking threads as solved?

Regards

Seamus

lucas
06-14-2008, 08:26 AM
Hi Seamus,
Yes, you can mark it solved using the thread tools at the top of the page...

SOS
06-14-2008, 03:18 PM
Hi Lucas,

Maybe I can't see it but I can't find where at the top of the page I can mark the thread as solved. When I click on Thread Tools I only get "Show Printable Version" and "Email This Page" and I can't see any other place to click to mark the thread as Solved :banghead: . Any more clues. :help