在我的宏中,我想提示页面方向 - P或p表示纵向,L或l表示横向。
这是我开发的内容。它有效 - 但想知道是否有更好/更有效的方法来开发If语句为“OR”---我是否必须使用“嵌套”If ??
Dim i As Integer
Dim oTbl As Table
Dim rng As Range
Dim Orientation As String
With Selection.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(0.4)
.RightMargin = InchesToPoints(0.4)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.6)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.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
' set Orientation
Orientation = InputBox(Prompt:="Enter P for Portriait, L for Landscape")
If Orientation = "L" Then
With Selection.PageSetup
.Orientation = wdOrientLandscape
End With
ElseIf Orientation = "l" Then
With Selection.PageSetup
.Orientation = wdOrientLandscape
End With
Else
With Selection.PageSetup
.Orientation = wdOrientPortrait
End With
End If
答案 0 :(得分:0)
我不确定是否有更好(更有效)的方式来开发MS Word页面方向...我不会使用if (!details.isEmpty()) {
details.get(0).getFirstElement();
}
,但如果您想使用它我会立即使用它做这样的事情:
InputBox
说实话......将决定留给用户,不要阻止用户从VBA代码设置页面方向,而是调用打印预览窗口。这是最好的方式 - 在我看来。