1

Тема: Создаем полезные функции и свойства объекта Page

Set сPage = New clsPage
Post's attachments

001.jpg
001.jpg 115.32 Кб, 2 скачиваний с 2012-05-17 

You don't have the permssions to download the attachments of this post.

2

Re: Создаем полезные функции и свойства объекта Page

Public Property Get mPageSetup() As PageSetup ' Настройка страницы
   Set mPageSetup = Me.Rectangle.Range.PageSetup
End Property

3

Re: Создаем полезные функции и свойства объекта Page

Public Property Get LeftMargin() As Single
   LeftMargin = Me.mPageSetup.LeftMargin
End Property

Public Property Get RightMargin() As Single
   RightMargin = Me.mPageSetup.RightMargin
End Property

Public Property Get TopMargin() As Single
   TopMargin = Me.mPageSetup.TopMargin
End Property

Public Property Get BottomMargin() As Single
   BottomMargin = Me.mPageSetup.BottomMargin
End Property

4

Re: Создаем полезные функции и свойства объекта Page

5

Re: Создаем полезные функции и свойства объекта Page

Далее модифицируем созданные нами ранее свойства:

Public Property Get PageWidth() As Single
   PageWidth = form_ClassInfo.Value(Me.mPageSetup.PageWidth)
End Property

Public Property Get PageHeight() As Single
   PageHeight = form_ClassInfo.Value(Me.mPageSetup.PageHeight)
End Property

Public Property Get PageSpace() As Single
   PageSpace = Me.PageWidth * Me.PageHeight
End Property

Public Property Get LeftMargin() As Single
   LeftMargin = form_ClassInfo.Value(Me.mPageSetup.LeftMargin)
End Property

Public Property Get RightMargin() As Single
   RightMargin = form_ClassInfo.Value(Me.mPageSetup.RightMargin)
End Property

Public Property Get TopMargin() As Single
   TopMargin = form_ClassInfo.Value(Me.mPageSetup.TopMargin)
End Property

Public Property Get BottomMargin() As Single
   BottomMargin = form_ClassInfo.Value(Me.mPageSetup.BottomMargin)
End Property

Public Property Get PrinttableWidth() As Single
   PrinttableWidth = Me.PageWidth - (Me.LeftMargin + Me.RightMargin)
End Property

Public Property Get PrinttableHeight() As Single
   PrinttableHeight = Me.PageHeight - (Me.TopMargin + Me.BottomMargin)
End Property

Public Property Get PrinttableSpace() As Single
   PrinttableSpace = Me.PrinttableWidth * Me.PrinttableHeight
End Property

Отредактировано aap77 (17.05.2012 21:57:54)

6

Re: Создаем полезные функции и свойства объекта Page

Private Sub Class_Initialize()
    Load form_ClassInfo
        Options.MeasurementUnit = wdMillimeters
        form_ClassInfo.opb_UnitApplication.Value = True
            With form_ClassInfo
                .opb_UnitInches.Enabled = False
                .opb_UnitCentimeters.Enabled = False
                .opb_UnitMillimeters.Enabled = False
                .opb_UnitPoints.Enabled = False
                .opb_Lines.Enabled = False
                .opb_UnitPicas.Enabled = False
                .Caption = "Информация о свойствах класса clsPage"
            End With
End Sub
Post's attachments

Blog1.dot 57 Кб, 2 скачиваний с 2012-05-17 

You don't have the permssions to download the attachments of this post.

7

Re: Создаем полезные функции и свойства объекта Page

Создадим в классе clsPage функцию форматирования числа и модернизируем свойства

Public Function FormatValue(Num As Variant) As Single
   FormatValue = Format(Num, "#####.#")
End Function
Public Property Get PageWidth() As Single
   PageWidth = Me.FormatValue(form_ClassInfo.Value(Me.mPageSetup.PageWidth))
End Property

Public Property Get PageHeight() As Single
   PageHeight = Me.FormatValue(form_ClassInfo.Value(Me.mPageSetup.PageHeight))
End Property

Public Property Get PageSpace() As Single
   PageSpace = Me.FormatValue(Me.PageWidth * Me.PageHeight)
End Property

Public Property Get LeftMargin() As Single
   LeftMargin = form_ClassInfo.Value(Me.mPageSetup.LeftMargin)
End Property

Public Property Get RightMargin() As Single
   RightMargin = Me.FormatValue(form_ClassInfo.Value(Me.mPageSetup.RightMargin))
End Property

Public Property Get TopMargin() As Single
   TopMargin = Me.FormatValue(form_ClassInfo.Value(Me.mPageSetup.TopMargin))
End Property

Public Property Get BottomMargin() As Single
   BottomMargin = Me.FormatValue(form_ClassInfo.Value(Me.mPageSetup.BottomMargin))
End Property

Public Property Get PrinttableWidth() As Single
   PrinttableWidth = Me.FormatValue(Me.PageWidth - (Me.LeftMargin + Me.RightMargin))
End Property

Public Property Get PrinttableHeight() As Single
   PrinttableHeight = Me.FormatValue(Me.PageHeight - (Me.TopMargin + Me.BottomMargin))
End Property

Public Property Get PrinttableSpace() As Single
   PrinttableSpace = Me.FormatValue(Me.PrinttableWidth * Me.PrinttableHeight)
End Property

8

Re: Создаем полезные функции и свойства объекта Page

Public Property Get PrinttableBounds() As Collection
Dim TopBounds As Collection, lstXY As Collection, Info As String
Dim CenterBounds As Collection
Dim BottomBounds As Collection
    Set PrinttableBounds = New Collection
    Set TopBounds = New Collection
    Set CenterBounds = New Collection
    Set BottomBounds = New Collection
        Set lstXY = New Collection
            lstXY.Add Me.FormatValue(Me.LeftMargin), "X"
            lstXY.Add Me.FormatValue(Me.TopMargin), "Y"
                Info = Info & "    Точка_1: X = " & lstXY(1) & "; "
                Info = Info & "Y = " & lstXY(2) & Chr(13)
            TopBounds.Add lstXY, "Bounds_1"
        Set lstXY = New Collection
            lstXY.Add Me.FormatValue((Me.LeftMargin + Me.PrinttableWidth) / 2), "X"
            lstXY.Add Me.FormatValue(Me.TopMargin), "Y"
                Info = Info & "    Точка_2: X = " & lstXY(1) & "; "
                Info = Info & "Y = " & lstXY(2) & Chr(13)
            TopBounds.Add lstXY, "Bounds_2"
        Set lstXY = New Collection
            lstXY.Add Me.FormatValue(Me.LeftMargin + Me.PrinttableWidth), "X"
            lstXY.Add Me.FormatValue(Me.TopMargin), "Y"
                Info = Info & "    Точка_3: X = " & lstXY(1) & "; "
                Info = Info & "Y = " & lstXY(2) & Chr(13)
            TopBounds.Add lstXY, "Bounds_3"
        Set lstXY = New Collection
            lstXY.Add Me.FormatValue(Me.LeftMargin), "X"
            lstXY.Add Me.FormatValue((Me.TopMargin + Me.PrinttableHeight) / 2), "Y"
                Info = Info & "    Точка_4: X = " & lstXY(1) & "; "
                Info = Info & "Y = " & lstXY(2) & Chr(13)
            CenterBounds.Add lstXY, "Bounds_4"
        Set lstXY = New Collection
            lstXY.Add Me.FormatValue((Me.LeftMargin + Me.PrinttableWidth) / 2), "X"
            lstXY.Add Me.FormatValue((Me.TopMargin + Me.PrinttableHeight) / 2), "Y"
                Info = Info & "    Точка_5: X = " & lstXY(1) & "; "
                Info = Info & "Y = " & lstXY(2) & Chr(13)
            CenterBounds.Add lstXY, "Bounds_5"
        Set lstXY = New Collection
            lstXY.Add Me.FormatValue(Me.LeftMargin + Me.PrinttableWidth), "X"
            lstXY.Add Me.FormatValue((Me.TopMargin + Me.PrinttableHeight) / 2), "Y"
                Info = Info & "    Точка_6: X = " & lstXY(1) & "; "
                Info = Info & "Y = " & lstXY(2) & Chr(13)
            CenterBounds.Add lstXY, "Bounds_6"
        Set lstXY = New Collection
            lstXY.Add Me.FormatValue(Me.LeftMargin), "X"
            lstXY.Add Me.FormatValue(Me.TopMargin + Me.PrinttableHeight), "Y"
                Info = Info & "    Точка_7: X = " & lstXY(1) & "; "
                Info = Info & "Y = " & lstXY(2) & Chr(13)
            BottomBounds.Add lstXY, "Bounds_7"
        Set lstXY = New Collection
            lstXY.Add Me.FormatValue((Me.LeftMargin + Me.PrinttableWidth) / 2), "X"
            lstXY.Add Me.FormatValue(Me.TopMargin + Me.PrinttableHeight), "Y"
                Info = Info & "    Точка_8: X = " & lstXY(1) & "; "
                Info = Info & "Y = " & lstXY(2) & Chr(13)
            BottomBounds.Add lstXY, "Bounds_8"
        Set lstXY = New Collection
            lstXY.Add Me.FormatValue((Me.LeftMargin + Me.PrinttableWidth)), "X"
            lstXY.Add Me.FormatValue(Me.TopMargin + Me.PrinttableHeight), "Y"
                Info = Info & "    Точка_9: X = " & lstXY(1) & "; "
                Info = Info & "Y = " & lstXY(2) & Chr(13)
            BottomBounds.Add lstXY, "Bounds_9"
    PrinttableBounds.Add TopBounds, "TopBounds"
    PrinttableBounds.Add CenterBounds, "CenterBounds"
    PrinttableBounds.Add BottomBounds, "BottomBounds"
    Info = "Координаты точек внутреннего поля:" & Chr(13) & Info
    PrinttableBounds.Add Info
End Property
Post's attachments

Blog1.dot 92 Кб, 1 скачиваний с 2012-05-17 

You don't have the permssions to download the attachments of this post.