Message 1 of 27
Object Variable Not Set Error
Not applicable
10-04-2007
03:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm making a VBA to make it easier and more user friendly to edit the attributes in our titleblock. I made a form with a bunch of textboxes and when it loads up, it fills in the textboxes with the attributes.
The program runs ok, but after it terminates, it gives the error message:
Run-time error '91':
Object variable or With block variable not set.
I'm not using a With block, so I assume I'm not setting something right.
Any ideas?
Private Sub UserForm_Initialize()
Dim oblkRef As AcadBlockReference
Dim objFnd As AcadEntity
Dim atts As Variant
For Each objFnd In ThisDrawing.PaperSpace
If TypeOf objFnd Is AcadBlockReference Then
Set oblkRef = objFnd
If StrComp(UCase(oblkRef.Name), "TITLEBLOCK", 1) = 0 Then
Exit For
End If
End If
Next objFnd
atts = oblkRef.GetAttributes
TextBox0.Text = atts(0).TextString
TextBox1.Text = atts(1).TextString
TextBox2.Text = atts(2).TextString
Me.Show
End Sub
I'm sure it's something "basic" (sorry) but I'm new to VBA.
Thanks.
The program runs ok, but after it terminates, it gives the error message:
Run-time error '91':
Object variable or With block variable not set.
I'm not using a With block, so I assume I'm not setting something right.
Any ideas?
Private Sub UserForm_Initialize()
Dim oblkRef As AcadBlockReference
Dim objFnd As AcadEntity
Dim atts As Variant
For Each objFnd In ThisDrawing.PaperSpace
If TypeOf objFnd Is AcadBlockReference Then
Set oblkRef = objFnd
If StrComp(UCase(oblkRef.Name), "TITLEBLOCK", 1) = 0 Then
Exit For
End If
End If
Next objFnd
atts = oblkRef.GetAttributes
TextBox0.Text = atts(0).TextString
TextBox1.Text = atts(1).TextString
TextBox2.Text = atts(2).TextString
Me.Show
End Sub
I'm sure it's something "basic" (sorry) but I'm new to VBA.
Thanks.