> I'm confused
I understand your confusion, believe me. ;)
Please be aware that I'm not a VBA whiz, and take note of any posts critical
of anything in the code I post. I can tell you that the snippets I'm
posting work well, in our company's circumstances. These were written
specifically for use here and most likely would need some amount of
modification for your use.
For finding the title block BLOCK, I use the following (note that this is a
snippet from a routine that goes to each layout being plotted and retrieves
information for storage in a database, no modifcation of the values was
required.)
Function GetTitleBlockInfo() As Variant
'========================================================================
Dim sTitle1 As String, sTitle2 As String, sTitle3 As String
Dim sDwgNum As String
Dim vRet(3) As Variant
Dim oLayout As AcadLayout, oLayBlock As AcadBlock
Dim oEnt As AcadEntity
Dim oBlkRef As AcadBlockReference
Set oLayout = ThisDrawing.ActiveLayout
Set oLayBlock = oLayout.Block
For Each oEnt In oLayBlock
If oEnt.ObjectName = "AcDbBlockReference" Then
Set oBlkRef = oEnt
Select Case oBlkRef.Name
Case "cectb30x42sd", "cectb24x36sd"
sTitle1 = GetAttTxtStr("TITLE_LINE_1", oBlkRef)
sTitle2 = GetAttTxtStr("TITLE_LINE_2", oBlkRef)
sTitle3 = GetAttTxtStr("TITLE_LINE_3", oBlkRef)
sDwgNum = GetAttTxtStr("PROJ_NO", oBlkRef) & "-" & _
GetAttTxtStr("DWG_NO", oBlkRef)
GoTo ValuesObtained
Case "30x42 Title", "30-42 Title Block", "24x36 Title Block", _
"Cec Title Block", "30-42_TITLE"
sTitle1 = GetAttTxtStr("TITLE_1", oBlkRef)
sTitle2 = GetAttTxtStr("TITLE_2", oBlkRef)
sTitle3 = GetAttTxtStr("TITLE_3", oBlkRef)
sDwgNum = GetAttTxtStr("DWG_NO", oBlkRef)
GoTo ValuesObtained
Case Else
sTitle1 = "": sTitle2 = "": sTitle3 = ""
sDwgNum = "000000"
End Select
End If
Next oEnt
ValuesObtained:
Set oBlkRef = Nothing
Set oLayBlock = Nothing
Set oLayout = Nothing
vRet(0) = sTitle1: vRet(1) = sTitle2: vRet(2) = sTitle3
vRet(3) = sDwgNum
GetTitleBlockInfo = vRet
End Function
The GetAttTxtStr function used in the above code is as follows:
Function GetAttTxtStr(sTagString As String, oBlkRef As AcadBlockReference)
As String
Dim vAttArr As Variant
Dim iAttCnt As Integer
Dim sRet As String
sRet = ""
If Not oBlkRef.HasAttributes Then GetAttTxtStr = sRet: Exit Function
vAttArr = oBlkRef.GetAttributes
For iAttCnt = 0 To UBound(vAttArr)
If vAttArr(iAttCnt).TagString = sTagString Then
GetAttTxtStr = vAttArr(iAttCnt).TextString
Exit Function
End If
Next
GetAttTxtStr = sRet
End Function
Again, a side note: The GetAttTxtStr could certainly use some tweaks, but
it works for here, so I didn't take it any further. It DOES have some
potential problems, though.
Hope that helps as opposed to hindering your grasp of the topic.