johnske
10-07-2004, 08:16 PM
Hi, I have a favourite page setup for Word docs that I want to use MOST of the time and I want new docs opened in the normal template to setup the pages using this setup if I choose it.
I'm not too sure exactly what I'll end up with, but I have the following inserted in the Normal template for "ThisDocument" for now. The problem is that I'm not sure of the syntax for deleting the button after use..... :bink:
Public MyObj As Object
Sub CreateCommandButton()
Set MyCtrl = ActiveDocument.Shapes _
.AddOLEControl(ClassType:="Forms.CommandButton.1")
With MyCtrl.OLEFormat
.Activate
Set MyObj = .Object
End With
With MyObj
.Caption = "Page Setup"
.AutoSize = True
End With
End Sub
Private Sub CommandButton1_Click()
SetupPage
End Sub
Sub SetupPage()
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.6)
.BottomMargin = InchesToPoints(0.97)
.LeftMargin = InchesToPoints(0.6)
.RightMargin = InchesToPoints(0.6)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.27)
.PageHeight = InchesToPoints(11.69)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With
ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitBestFit
Selection.Font.Name = "Verdana"
Shapes(MyObj).Select
Selection.Cut
End Sub
I'm not too sure exactly what I'll end up with, but I have the following inserted in the Normal template for "ThisDocument" for now. The problem is that I'm not sure of the syntax for deleting the button after use..... :bink:
Public MyObj As Object
Sub CreateCommandButton()
Set MyCtrl = ActiveDocument.Shapes _
.AddOLEControl(ClassType:="Forms.CommandButton.1")
With MyCtrl.OLEFormat
.Activate
Set MyObj = .Object
End With
With MyObj
.Caption = "Page Setup"
.AutoSize = True
End With
End Sub
Private Sub CommandButton1_Click()
SetupPage
End Sub
Sub SetupPage()
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.6)
.BottomMargin = InchesToPoints(0.97)
.LeftMargin = InchesToPoints(0.6)
.RightMargin = InchesToPoints(0.6)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.27)
.PageHeight = InchesToPoints(11.69)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With
ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitBestFit
Selection.Font.Name = "Verdana"
Shapes(MyObj).Select
Selection.Cut
End Sub