Changing Dynamic Block Property Values with VBA

Changing Dynamic Block Property Values with VBA

Anonymous
Not applicable
6,943 Views
5 Replies
Message 1 of 6

Changing Dynamic Block Property Values with VBA

Anonymous
Not applicable
I have found several threads concerning manipulation of Dynamic blocks using VBA. Most of them tend to have
a variation of the code posted below, which appears to
work great if you are trying to change the visibility property.

Private Sub ScanBlks()
Dim dybprop As Variant, i As Integer
Dim bobj As AcadEntity
For Each bobj In ThisDrawing.ModelSpace
If bobj.ObjectName = "AcDbBlockReference" Then
If bobj.IsDynamicBlock Then
If bobj.EffectiveName = "cirtagleader" Then
dybprop = bobj.GetDynamicBlockProperties
For i = LBound(dybprop) To UBound(dybprop)
If dybprop(i).PropertyName = "Visibility" Then
dybprop(i).Value = "Leader Off"
End If
Next i
End If
End If
End If
Next

End Sub

However if I replace the following code:

If dybprop(i).PropertyName = "Visibility" Then
dybprop(i).Value = "Leader Off"

With

If dybprop(i).PropertyName = "Distance1" Then
dybprop(i).Value = 36

I get
"Run-time error '438':
Object doesn't support this property or method"

Any help would be more than appreciated,
Thanks in advance,
Chris
0 Likes
6,944 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Actually I get the following error:

Run-time error '-2145386493 (80200003)':
Invalid input
0 Likes
Message 3 of 6

Anonymous
Not applicable
Try This:

dybprop(i).Value = 36#

Hope it helps,
Dan


wrote in message news:[email protected]...
Actually I get the following error:

Run-time error '-2145386493 (80200003)':
Invalid input
Message 4 of 6

Anonymous
Not applicable
Yep, that did it.
Thanks!!!
0 Likes
Message 5 of 6

carlosrgns
Participant
Participant

ur solution works perfect for me too, now... what does the "#" do?

0 Likes
Message 6 of 6

carlosrgns
Participant
Participant

and i answered myself in seconds, will change the number type to double