Макрос определения ориентации и формата страницыИсточник: wordexpert Антон Кокин
Имеется документ с несколькими страницами, которые имеют разную ориентацию и формат (А4 и А3). Как определить формат и ориентацию текущей страницы? Для этих целей можно воспользоваться, например, таким макросом (с функцией): Sub Ident_Orient_PaperSize() 'Определение ориентации и формата страницы документа If Selection.PageSetup.Orientation = wdOrientLandscape Then MsgBox "Ориентация текущей страницы - Альбомная" & vbCr _ & "Формат страницы - " & PaperSizeDoc(Selection.PageSetup.PaperSize) Else MsgBox "Ориентация текущей страницы - Книжная" & vbCr _ & "Формат страницы - " & PaperSizeDoc(Selection.PageSetup.PaperSize) End If End Sub Public Function PaperSizeDoc(iPS As Long) As String Dim ps(42) As String iPS = Selection.PageSetup.PaperSize ps(0) = "wdPaper10x14" ps(1) = "wdPaper11x17" ps(2) = "wdPaperLetter" ps(3) = "wdPaperLetterSmall" ps(4) = "wdPaperLegal" ps(5) = "wdPaperExecutive" ps(6) = "wdPaperA3" ps(7) = "wdPaperA4" ps(8) = "wdPaperA4Small" ps(9) = "wdPaperA5" ps(10) = "wdPaperB4" ps(11) = "wdPaperB5" ps(12) = "wdPaperCSheet" ps(13) = "wdPaperDSheet" ps(14) = "wdPaperESheet" ps(15) = "wdPaperFanfoldLegalGerman" ps(16) = "wdPaperFanfoldStdGerman" ps(17) = "wdPaperFanfoldUS" ps(18) = "wdPaperFolio" ps(19) = "wdPaperLedger" ps(20) = "wdPaperNote" ps(21) = "wdPaperQuarto" ps(22) = "wdPaperStatement" ps(23) = "wdPaperTabloid" ps(24) = "wdPaperEnvelope9" ps(25) = "wdPaperEnvelope10" ps(26) = "wdPaperEnvelope11" ps(27) = "wdPaperEnvelope12" ps(28) = "wdPaperEnvelope14" ps(29) = "wdPaperEnvelopeB4" ps(30) = "wdPaperEnvelopeB5" ps(31) = "wdPaperEnvelopeB6" ps(32) = "wdPaperEnvelopeC3" ps(33) = "wdPaperEnvelopeC4" ps(34) = "wdPaperEnvelopeC5" ps(35) = "wdPaperEnvelopeC6" ps(36) = "wdPaperEnvelopeC65" ps(37) = "wdPaperEnvelopeDL" ps(38) = "wdPaperEnvelopeItaly" ps(39) = "wdPaperEnvelopeMonarch" ps(40) = "wdPaperEnvelopePersonal" ps(41) = "wdPaperCustom" PaperSizeDoc = ps(iPS) End Function |