Re: Общая форма для просмотра свойств Класса
Re: Общая форма для просмотра свойств Класса
Для вставки формы в Ваш проект разархивируйте вложенный архив в какую-нибудь папку.
Откройте редактор VBA, выберете проект Normal, выведете правым кликом всплывающее меню и выберете ImportFile. Укажите путь к разархивированному файлу с расширением .frm
Re: Общая форма для просмотра свойств Класса
После создания интерфейса формы откроем окно кода формы и создадим свойство Unit(Единица измерения), для радиокнопок находящихся в рамке «Единицы измерения» события Chenge
Public Unit As WdMeasurementUnits
Private Sub opb_Lines_Change()
If Me.opb_Lines.Value = True Then
Me.Unit = wdPicas
End If
End Sub
Private Sub opb_UnitApplication_Change()
If Me.opb_UnitApplication.Value = True Then
Me.Unit = ThisDocument.Application.Options.MeasurementUnit
End If
End Sub
Private Sub opb_UnitCentimeters_Change()
If Me.opb_UnitCentimeters.Value = True Then
Me.Unit = wdCentimeters
End If
End Sub
Private Sub opb_UnitInches_Change()
If Me.opb_UnitInches.Value = True Then
Me.Unit = wdInches
End If
End Sub
Private Sub opb_UnitMillimeters_Change()
If Me.opb_UnitMillimeters.Value = True Then
Me.Unit = wdMillimeters
End If
End Sub
Private Sub opb_UnitPicas_Change()
If Me.opb_UnitPicas.Value = True Then
Me.Unit = wdPicas
End If
End Sub
Private Sub opb_UnitPoints_Change()
If Me.opb_UnitPoints.Value = True Then
Me.Unit = wdPoints
End If
End SubОтредактировано aap77 (17.05.2012 20:04:22)
Re: Общая форма для просмотра свойств Класса
Далее создадим функцию перевода единиц измерения в зависимости от свойства Unit:
Public Function Value(Num As Variant) As Single
If Me.Unit = wdInches Then
Value = PointsToInches(Num)
Exit Function
ElseIf Me.Unit = wdCentimeters Then
Value = PointsToCentimeters(Num)
Exit Function
ElseIf Me.Unit = wdMillimeters Then
Value = PointsToMillimeters(Num)
Exit Function
ElseIf Me.Unit = wdPoints Then
Value = Num
Exit Function
ElseIf Me.Unit = wdPicas Then
Value = PointsToPicas(Num)
Exit Function
End If
End FunctionRe: Общая форма для просмотра свойств Класса
Теперь создадим свойство Info в котором будет содержаться текст выводимой информации.
Общий код для созданной нами формы будет выглядеть так:
Public Unit As WdMeasurementUnits
Dim Info As String
Private Sub opb_Lines_Change()
If Me.opb_Lines.Value = True Then
Me.Unit = wdPicas
End If
End Sub
Private Sub opb_UnitApplication_Change()
If Me.opb_UnitApplication.Value = True Then
Me.Unit = ThisDocument.Application.Options.MeasurementUnit
End If
End Sub
Private Sub opb_UnitCentimeters_Change()
If Me.opb_UnitCentimeters.Value = True Then
Me.Unit = wdCentimeters
End If
End Sub
Private Sub opb_UnitInches_Change()
If Me.opb_UnitInches.Value = True Then
Me.Unit = wdInches
End If
End Sub
Private Sub opb_UnitMillimeters_Change()
If Me.opb_UnitMillimeters.Value = True Then
Me.Unit = wdMillimeters
End If
End Sub
Private Sub opb_UnitPicas_Change()
If Me.opb_UnitPicas.Value = True Then
Me.Unit = wdPicas
End If
End Sub
Private Sub opb_UnitPoints_Change()
If Me.opb_UnitPoints.Value = True Then
Me.Unit = wdPoints
End If
End Sub
Public Function Value(Num As Variant) As Single
If Me.Unit = wdInches Then
Value = PointsToInches(Num)
Exit Function
ElseIf Me.Unit = wdCentimeters Then
Value = PointsToCentimeters(Num)
Exit Function
ElseIf Me.Unit = wdMillimeters Then
Value = PointsToMillimeters(Num)
Exit Function
ElseIf Me.Unit = wdPoints Then
Value = Num
Exit Function
ElseIf Me.Unit = wdPicas Then
Value = PointsToPicas(Num)
Exit Function
End If
End FunctionВо вложении находится файл созданной формы
Отредактировано aap77 (17.05.2012 21:08:37)
Re: Общая форма для просмотра свойств Класса
Ну
