Microsoft Office Tutorials and References
In Depth Information
Transferring a Selection to a New Document
'Assign the selection to its variable¶
Set rngSel = Selection.Range¶
Set origSetup = rngSel.Sections(1).PageSetup¶
'Create a new document from the current document¶
'So that styles, etc. are all present¶
Set docNew = Documents.Add(ActiveDocument.FullName)¶
'Delete everything¶
docNew.Range.Delete¶
'Put the selection into the new document¶
docNew.Range.FormattedText = rngSel.FormattedText¶
'Set the page properties to correspond¶
'to the settings for the section in which¶
'the selection was made¶
With docNew.Sections(1).PageSetup¶
.BottomMargin = origSetup.BottomMargin¶
.TopMargin = origSetup.TopMargin¶
.LeftMargin = origSetup.LeftMargin¶
.RightMargin = origSetup.RightMargin¶
.Gutter = origSetup.Gutter¶
'Comment out the next two lines for Wor97¶
'and Word 2000¶
.GutterPos = origSetup.GutterPos¶
.GutterStyle = origSetup.GutterStyle¶
.DifferentFirstPageHeaderFooter = _¶
origSetup.DifferentFirstPageHeaderFooter¶
.OddAndEvenPagesHeaderFooter = _¶
origSetup.OddAndEvenPagesHeaderFooter¶
.FooterDistance = origSetup.FooterDistance¶
.HeaderDistance = origSetup.HeaderDistance¶
.MirrorMargins = origSetup.MirrorMargins¶
.Orientation = origSetup.Orientation¶
.PaperSize = origSetup.PaperSize¶
.PageHeight = origSetup.PageHeight¶
.PageWidth = origSetup.PageWidth¶
With .TextColumns¶
.SetCount numcolumns:=origSetup.TextColumns.Count¶
.EvenlySpaced = origSetup.TextColumns.EvenlySpaced¶
.LineBetween = origSetup.TextColumns.LineBetween¶
If .Count > 1 And .EvenlySpaced Then¶
'Variable declaration¶
Dim i As Long¶
.Spacing = origSetup.TextColumns.Spacing¶
If .Spacing = False Then¶
For i = 1 To .Count¶
.Item(i).SpaceAfter = _¶
origSetup.TextColumns(i).SpaceAfter¶
.Item(i).Width = _¶
origSetup.TextColumns(i).Width¶
Next¶
End If¶
Wrd
Search JabSto ::




Custom Search