Attribute VB_Name = "Modul2"
Public Sub InsertTitleBlockOnSheet()
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
' Obtain a reference to the desired border definition.
Dim oTitleBlockDef As TitleBlockDefinition
Set oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item("Neuer Zeichnungskopf")
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
' Check to see if the sheet already has a title block and delete it if it does.
If Not oSheet.TitleBlock Is Nothing Then
oSheet.TitleBlock.Delete
End If
' Add an instance of the title block definition to the sheet.
Dim oTitleBlock As TitleBlock
Set oTitleBlock = oSheet.AddTitleBlock(oTitleBlockDef)
End Sub
Public Sub CreateTitleBlockDefinition()
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
' Create the new title block definition.
Dim oTitleBlockDef As TitleBlockDefinition
Set oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Add("Neuer Zeichnungskopf")
' Open the title block definition's sketch for edit. This is done by calling the Edit
' method of the TitleBlockDefinition to obtain a DrawingSketch. This actually creates
' a copy of the title block definition's and opens it for edit.
Dim oSketch As DrawingSketch
Call oTitleBlockDef.Edit(oSketch)
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
' Use the functionality of the sketch to add title block graphics.
Call oSketch.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(0, 0), oTG.CreatePoint2d(9, 3))
' Add some static text to the title block.
Dim sText As String
' sText = "TITLE BLOCK"
sText = "TITLE BLOCK"
Dim oTextBox As TextBox
Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(4.5, 1.5), sText)
oTextBox.VerticalJustification = kAlignTextMiddle
oTextBox.HorizontalJustification = kAlignTextCenter
Call oTitleBlockDef.ExitEdit(True)
End Sub