tplanitz
Erfahrenes Mitglied
Hallo liebe Gemeinde,
Schnellbausteine erlauben es, dass man Sie mit unterschiedlichen Fonts(z.B Schriftart, Schriftgröße) anlegt.
Nun habe ich ein Script geschrieben, dass mir die sogenannten BuildingBlocks und deren BuildingBlockEntries herauszieht aus der Nomal.dotm oder aus der eigenen Schnellbaustein.dotm.
Leider gelingt mir der letzte Schritt nicht, die Fontart und die Fontgröße über ein RangeObject aneigen zu lassen.
Hat jemand einen Ansatz oder Idee wie ich weiter vorgehen muss?
HIer der Code:
Schnellbausteine erlauben es, dass man Sie mit unterschiedlichen Fonts(z.B Schriftart, Schriftgröße) anlegt.
Nun habe ich ein Script geschrieben, dass mir die sogenannten BuildingBlocks und deren BuildingBlockEntries herauszieht aus der Nomal.dotm oder aus der eigenen Schnellbaustein.dotm.
Leider gelingt mir der letzte Schritt nicht, die Fontart und die Fontgröße über ein RangeObject aneigen zu lassen.
Hat jemand einen Ansatz oder Idee wie ich weiter vorgehen muss?
HIer der Code:
Code:
Sub DisplayCustomBuildingBlock()
Dim objTemplate As Template
Dim objBB2 As BuildingBlock
Dim objRange As Range
Dim iCount As Integer
Dim jCount As Integer
Dim zCount As Integer
' Set the template to store the building block
zCount = Templates.Count
For iCount = 1 To zCount
Debug.Print "==> Template Name: " + Templates(iCount).Name
If Templates(iCount).Name = "Normal.dotm" Then
Set objTemplate = Templates(iCount)
End If
Next iCount
Debug.Print "===> " + Str(iCount) + ". TEMPALTE NAME/TYPE: "; objTemplate.Path & Application.PathSeparator & objTemplate.Name & " template type: " & objTemplate.Type
' Parse the building block entries for text font and text size
For iCount = 1 To objTemplate.BuildingBlockEntries.Count
Set objBB2 = objTemplate.BuildingBlockEntries(iCount)
selection.Text = objBB2.Value
Set objRange = selection.Range
' This is working all names , types and categories are displayed
Debug.Print "====> objBB2.Name: " + objBB2.Name + " ==> value: " + objBB2.Value + " ==> category: " + objBB2.Category.Name
' This does not work only the same fond and font size is displayed although three different Building Blocks are configured
Debug.Print "+++++ " + objRange.Text + " Font: " + objRange.Font.Name + " Font Size: " + Str(objRange.Font.Size)
Next iCount
End Sub
Zuletzt bearbeitet: