Change Font Size of Text Box


Hi Guys, hope someone can help with this simple task


i have searched the forum but not found an answer.

i have copied and butchered someone else's code to produce what i have shown below,

The idea is to check and correct all text on a drawing to make sure its all the same

font, size, style etc.

I have got it working for font, but i cant find a way to set the font height,

i believe it should be


but i cant get it to work, keeps complaining about a Null reference

Another approach would be if i could set all text (textbox and dims) to a defined style


This is the problem part of the code below




objApp AsSolidEdgeFramework.Application




Dim objDoc AsSolidEdgeDraft.DraftDocument




Dim objSheet AsSolidEdgeDraft.Sheet




Dim objSectionSheets AsSolidEdgeDraft.SectionSheets




Dim objDimStyle AsSolidEdgeFrameworkSupport.DimensionStyle




Dim objDimStyles AsSolidEdgeFrameworkSupport.DimensionStyles




Dim objTextBox AsSolidEdgeFrameworkSupport.TextBox




Dim objTextBoxes AsSolidEdgeFrameworkSupport.TextBoxes




Dim objTextEdit AsSolidEdgeFrameworkSupport.TextEdit




Dim d AsInteger 




'Connect to Solid Edge

objApp = Marshal.GetActiveObject(





'Get Reference to active document

objDoc = objApp.ActiveDocument


'This is where i get the problem,

objTextEdit = objDoc.TextEdit   ->   does not list TextEdit

objTextEdit.TextSize = (3)




'Code to gloablly change font in all dimension styles

objDimStyles = objDoc.DimensionStyles


 ForEach objDimStyle In objDimStyles





objDimStyle.Font = "Arial"



Thanks Guys

 "Comic Sans MS""SolidEdge.Application")


Posted by: Paul McGiven
Post date: 8/6/2009 1:17:33 AM


RE: Change Font Size of Text Box




you set objTextEdit = objDoc.TextEdit but TextEdit is a property of TextBox not from objDoc


Try this:


For i = 1 To objDoc.Sheets.Count

 For j = 1 To objDoc.Sheets(i).TextBoxes.Count


  objTextEdit = objTextBoxes(j).Edit


 Next j

Next i





Posted by: JR
Post date: 8/10/2009 11:46:38 PM

RE: Change Font Size of Text Box

Thanks JR but i still get


Object variable or With block variable not set.




objTextEdit = objTextBoxes(j).Edit




Posted by: Paul McGiven
Post date: 8/11/2009 3:13:32 AM

RE: Change Font Size of Text Box


Hi Paul,


I forgot that in vb.Net sometimes called "ITEM" is needed (Item is not set to default property).


Try this:


For i = 1 To objDoc.Sheets.Count

  For j = 1 To objDoc.Sheets.Item(i).TextBoxes.Count

   objTextBoxes = objDoc.Sheets.Item(i).TextBoxes

   objTextEdit = objTextBoxes.Item(j).Edit

   objTextEdit.TextSize = 0.003

  Next j

Next i


If you have groups with TextBoxes on the sheets you must loop the groups too.





Posted by: JR
Post date: 8/11/2009 7:29:48 PM

RE: Change Font Size of Text Box

Thanks JR, but i figured it out, shown below

For d = 1 To Working_Sheets_Per_Drawing

objSheet = objSectionSheets.Item(d)


objTextBoxes = objSheet.TextBoxes()

For Each objTextBox In objTextBoxes

'objTextBox.Edit.Font = "Arial"

objTextBox.Edit.Font = SelFont


objTextBox.Edit.TextSize = FontSize ' 0.005 = 5mm, was (0.005)




this works a treat on textboxes, now trying to get it to work on dimension text

the following works on the dim text font


objDimStyles = objDoc.DimensionStyles

For Each objDimStyle In objDimStyles

objDimStyle.Font = SelFont

'Need to change dimension text size




Just need now to change the dimension text font size.


When i started this small program i did not think it would be such a problem,

to be honest you would think SE would have a built in function to allow you to

set all text on a drawing to the same font / size.



Posted by: Paul McGiven
Post date: 8/12/2009 10:39:18 PM

RE: Change Font Size of Text Box

I don't know the Funktion to change the font of all TexBoxes.


For DimStyles use objDimStyle.Height to change the font size.

After the Loop you must refresh the view, for example with:




Posted by: JR
Post date: 8/12/2009 11:10:31 PM