Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

code for conversion from portrait to landscape.

Former Member
0 Likes
363

hi everybody, i cerated one program in ole that creates certificates in msword, the output is comming in portrait , but i need in landscape, could any one tell the code or any method or property for that, very urgent.

Regards,

sudhir

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
313

Hi Sudhir,

Please find the macro recording for converting from portrait to landscape.

Try to impliment the same in your program.

With ActiveDocument.Styles(wdStyleNormal).Font

If .NameFarEast = .NameAscii Then

.NameAscii = ""

End If

.NameFarEast = ""

End With

With ActiveDocument.PageSetup

.LineNumbering.Active = False

.Orientation = wdOrientPortrait

.TopMargin = CentimetersToPoints(2.54)

.BottomMargin = CentimetersToPoints(2.54)

.LeftMargin = CentimetersToPoints(3.17)

.RightMargin = CentimetersToPoints(3.17)

.Gutter = CentimetersToPoints(0)

.HeaderDistance = CentimetersToPoints(1.27)

.FooterDistance = CentimetersToPoints(1.27)

.PageWidth = CentimetersToPoints(21.59)

.PageHeight = CentimetersToPoints(27.94)

.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

End With

End Sub

Sub testmacro()

'

' testmacro Macro

' Macro recorded 12/29/2005 by venugopal.yelishetty

'

End Sub

Sub test()

'

' test Macro

' Macro recorded 12/29/2005 by venugopal.yelishetty

'

With ActiveDocument.Styles(wdStyleNormal).Font

If .NameFarEast = .NameAscii Then

.NameAscii = ""

End If

.NameFarEast = ""

End With

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.27)

.FooterDistance = CentimetersToPoints(1.27)

.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

End With

End Sub

Please close the issue with appropriate points if helpful.

Good luck.

Venu

1 REPLY 1
Read only

Former Member
0 Likes
314

Hi Sudhir,

Please find the macro recording for converting from portrait to landscape.

Try to impliment the same in your program.

With ActiveDocument.Styles(wdStyleNormal).Font

If .NameFarEast = .NameAscii Then

.NameAscii = ""

End If

.NameFarEast = ""

End With

With ActiveDocument.PageSetup

.LineNumbering.Active = False

.Orientation = wdOrientPortrait

.TopMargin = CentimetersToPoints(2.54)

.BottomMargin = CentimetersToPoints(2.54)

.LeftMargin = CentimetersToPoints(3.17)

.RightMargin = CentimetersToPoints(3.17)

.Gutter = CentimetersToPoints(0)

.HeaderDistance = CentimetersToPoints(1.27)

.FooterDistance = CentimetersToPoints(1.27)

.PageWidth = CentimetersToPoints(21.59)

.PageHeight = CentimetersToPoints(27.94)

.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

End With

End Sub

Sub testmacro()

'

' testmacro Macro

' Macro recorded 12/29/2005 by venugopal.yelishetty

'

End Sub

Sub test()

'

' test Macro

' Macro recorded 12/29/2005 by venugopal.yelishetty

'

With ActiveDocument.Styles(wdStyleNormal).Font

If .NameFarEast = .NameAscii Then

.NameAscii = ""

End If

.NameFarEast = ""

End With

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.27)

.FooterDistance = CentimetersToPoints(1.27)

.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

End With

End Sub

Please close the issue with appropriate points if helpful.

Good luck.

Venu