Message 1 of 13
Add Text to a Drawing Dimension

Not applicable
06-12-2007
11:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The following code works in IV9 but not IV11. I get the text box, but the text box entry does not make it to the drawing dimension. What should I change?
Public Sub AddTextToDrawingDimension()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
'User an Inputbox so a user can enter the text he wants behind thedimension
Dim sUserText As String
sUserText = Trim(InputBox("Enter hole Qty. to be placed behind dimension or hit for none.", "Addsuffix to dimension"))
' Find all selected occurrences and add them to an ObjectCollection.
Dim oDrawingDims() As DrawingDimension
Dim a As Integer
a = 0
Dim i As Long
For i = 1 To oDrawDoc.SelectSet.Count
If Not oDrawDoc.SelectSet.Item(i) Is Nothing Then
If TypeOf oDrawDoc.SelectSet.Item(i) Is DrawingDimension Then
'Only add Dimensions to the ObjectCollection
a = a + 1
ReDim Preserve oDrawingDims(0 To a)
Set oDrawingDims(a) = oDrawDoc.SelectSet.Item(i)
End If
End If
Next
Dim n As Integer
For n = 1 To a
'MsgBox " text is " & sUserText
If sUserText = "" Then
oDrawingDims(n).Text.FormattedText = "<<>>"
Else
oDrawingDims(n).Text.FormattedText = "(" & sUserText & ")"
End If
' for IV 9, replace with << >>
Next
End Sub
Thanks,
Jon
Public Sub AddTextToDrawingDimension()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
'User an Inputbox so a user can enter the text he wants behind thedimension
Dim sUserText As String
sUserText = Trim(InputBox("Enter hole Qty. to be placed behind dimension or hit
' Find all selected occurrences and add them to an ObjectCollection.
Dim oDrawingDims() As DrawingDimension
Dim a As Integer
a = 0
Dim i As Long
For i = 1 To oDrawDoc.SelectSet.Count
If Not oDrawDoc.SelectSet.Item(i) Is Nothing Then
If TypeOf oDrawDoc.SelectSet.Item(i) Is DrawingDimension Then
'Only add Dimensions to the ObjectCollection
a = a + 1
ReDim Preserve oDrawingDims(0 To a)
Set oDrawingDims(a) = oDrawDoc.SelectSet.Item(i)
End If
End If
Next
Dim n As Integer
For n = 1 To a
'MsgBox " text is " & sUserText
If sUserText = "" Then
oDrawingDims(n).Text.FormattedText = "<<>>"
Else
oDrawingDims(n).Text.FormattedText = "(" & sUserText & ")"
End If
' for IV 9, replace
Next
End Sub
Thanks,
Jon