PDA

View Full Version : [SOLVED:] Help for Landscape printing and Header



Mr Doubtfire
09-26-2005, 06:28 PM
I have created a Word document for printing reports. The last part that is left now is how to switch to Landscape mode for printing and add headers.

I would like the header to have


Date:(left indented) Page No (right indented)
Sales report (centered)

For header setting up I need to change Fonts/Bold face, and center/left/right indented.
******I have recorded a macro but it did not succeed.
Thanks.:banghead:

geekgirlau
09-26-2005, 06:32 PM
Can you post the macro you recorded?

MOS MASTER
09-27-2005, 01:25 AM
Switching between Landscape and Portrait can have unexpected results if the format of your document doesn't allow it. (And it rarely does)

Normaly a document is formatted for landscape (Page setup easy to code) and all will print neatly when you execute printout. But if you printout a portrait setup document as Landscape you'll have a lot of landscape extra pages with still a portrait layout.

Just try it out manualy first ... I don't think it will be easy to get all the formats right if you change from portrait to landscape. (Deppending on used formats)

HTH, :whistle:

Mr Doubtfire
09-27-2005, 04:43 PM
The macro is as followed:-


With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = CentimetersToPoints(3.17)
.BottomMargin = CentimetersToPoints(3.17)
.LeftMargin = CentimetersToPoints(2.54)
.RightMargin = CentimetersToPoints(2.54)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.25)
.FooterDistance = CentimetersToPoints(1.25)
.PageWidth = CentimetersToPoints(27.94)
.PageHeight = CentimetersToPoints(21.59)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
.LayoutMode = wdLayoutModeDefault
End With
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
NormalTemplate.AutoTextEntries("Author, Page #, Date").Insert Where:= _
Selection.Range, RichText:=True
Selection.HomeKey Unit:=wdLine
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:=vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & _
"Page : "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldPage
Selection.TypeParagraph
Selection.TypeText Text:=vbTab & "VBA Company."
Selection.MoveLeft Unit:=wdCharacter, Count:=13
Selection.TypeText Text:= _
" "
Selection.TypeText Text:=" "
Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Selection.TypeText Text:=vbTab & "Sales performance weekly status"
Selection.HomeKey Unit:=wdLine
Selection.TypeText Text:=vbTab
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:= _
" "
Selection.TypeText Text:=" "
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Bold = wdToggle
Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Selection.TypeText Text:=vbTab
Selection.Font.Bold = wdToggle
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.CorrectHangulEndings = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.MatchFuzzy = False
End With
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.CorrectHangulEndings = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.MatchFuzzy = False
End With
Selection.TypeText Text:= _
"From date1 to date2"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument


Please advice.

Bilby
09-28-2005, 05:59 PM
Hi

Try setting up separate Header styles and useing them to format your header paragraphs. Something like ...


...
Selection.Style = ActiveDocument.Styles("Header1")
Selection.TypeText Text:=vbTab & "VBA Company."
...

Mr Doubtfire
09-28-2005, 07:01 PM
Thanks. I got it.
But a question. On the header I have date on the left side and it appears to be
28/09/2005, how I could format to September 28, 2005!?
Please advice.:(