Is it possible to create a Textbox object on a Visio page using VBA code?
You can try macro recroder. Start recording, insert the Textbox and see what the recorder produced. For me it produced the following:
Application.ActiveWindow.Page.InsertObject "{8BD21D10-EC42-11CE-9E0D-00AA006002F3}", visInsertAsControl + visInsertNoDesignModeTransition
Thanks!. This is what I came up with
Sub cre8TextBox()
Application.EventsEnabled = False
Dim vsoPage As Visio.Page
Set vsoPage = Visio.ActivePage
'// Create TextBox
Dim oTB As Object
Set oTB = vsoPage.InsertObject("{8BD21D10-EC42-11CE-9E0D-00AA006002F3}", visInsertAsControl + visInsertNoDesignModeTransition)
With oTB
.Object.Name = "tbRFCNumber"
.Object.Text = "RFC-yyyy-####"
End With
'// Position and Format TextBox
If Not oTB Is Nothing Then
Dim vsoShape As Visio.Shape
Set vsoShape = oTB
vsoShape.Cells("Width").formula = "=1.625 in."
vsoShape.Cells("Height").formula = "=0.375 in."
vsoShape.Cells("PinX").formula = "=11.75 in."
vsoShape.Cells("PinY").formula = "=10 in."
vsoShape.CellsSRC(visSectionCharacter, visRowFirst, visCharacterSize).formula = "=12 pt"
vsoShape.CellsSRC(visSectionCharacter, visRowFirst, visCharacterFont).formula = "=21"
End If
Application.EventsEnabled = True
Set oTB = Nothing
End Sub
Unless you mean just a simple text box, which is just a simple rectangle with LinePattern set to =THEMEGUARD(0)