Please find the code:
Private Sub ModifyFrameBlock()
Dim AutoCadApp As Object
Dim dwg As AcadDocument
Dim blkName As String
Dim i, j As Integer
Dim blk As AcadBlockReference
Dim blks() As AcadBlockReference
Dim attrs As Variant
Dim attr As AcadAttributeReference
Dim blcksObj As AcadSelectionSet
Dim TITLE_1, TITLE_2, SCALE1, SECTION, SYSTEM As String
Dim REVISION, SHEET11, REFNUM, PREL, GFA, GFU, ASBUILT, datRev As String
Dim IndA, IndADate, IndAmod1, IndAmod2, IndAdesign, IndAcheck, IndAcheckApp, IndAapprovedSTX As String
Set AutoCadApp = GetObject(, "AutoCAD.Application")
Set dwg = AutoCadApp.ActiveDocument
TITLE_1 = DrawingTable.TextBox1.value
TITLE_2 = DrawingTable.TextBox2.value
SCALE1 = DrawingTable.ComboBox2.value
SECTION = DrawingTable.TextBox6.value
SYSTEM = DrawingTable.TextBox7.value
datRev = REVISION
SHEET11 = DrawingTable.TextBox9.value
REFNUM = DrawingTable.TextBox10.value
PREL = DrawingTable.TextBox11.value
GFA = DrawingTable.TextBox12.value
GFU = DrawingTable.TextBox13.value
ASBUILT = DrawingTable.TextBox14.value
IndA = REVISION
DrawingTable.TextBox19 = REVISION
IndADate = DrawingTable.TextBox16.value
IndAmod1 = DrawingTable.TextBox17.value
IndAmod2 = DrawingTable.TextBox18.value
IndAdesign = DrawingTable.ComboBox3.value
IndAcheck = DrawingTable.ComboBox4.value
IndAcheckApp = DrawingTable.ComboBox5.value
'blkName = "DwgTable01"
'blkName = "CDD_J35_AER_Header_ACDL_Attr"
Set blcksObj = FindBlocksOnAllLayouts2(dwg, blkName)
If blcksObj.Count > 0 Then ' if any block found
ReDim Preserve blks(0 To blcksObj.Count)
For Each blk In blcksObj
If UCase(blk.EffectiveName) = "CDD_J35_AER_Header_ACDL_Attr" And blk.HasAttributes Then
Set blks(i) = blk
i = i + 1
End If
Next
On Error GoTo ERRORHANDLER
If i = 0 Then
MsgBox "No blocks """ & blkName & """ with attributes found in current drawing!"
Else
ReDim Preserve blks(0 To i - 1)
For i = 0 To UBound(blks)
Set blk = blks(i)
attrs = blk.GetAttributes()
For j = 0 To UBound(attrs)
Set attr = attrs(j)
If attr.TagString = "TITLE_1" Then
attr.TextString = TITLE_1
ElseIf attr.TagString = "TITLE_2" Then
attr.TextString = TITLE_2
ElseIf attr.TagString = "SCALE" Then
attr.TextString = SCALE1
ElseIf attr.TagString = "SECTION" Then
attr.TextString = SECTION
ElseIf attr.TagString = "SYSTEM" Then
attr.TextString = SYSTEM
ElseIf attr.TagString = "REVISION" Then
attr.TextString = REVISION
ElseIf attr.TagString = "SHEET" Then
attr.TextString = SHEET11
ElseIf attr.TagString = "REFERENCE_NUMBER" Then
attr.TextString = REFNUM
ElseIf attr.TagString = "PRELIMINARY" Then
attr.TextString = PREL
ElseIf attr.TagString = "GOOD_FOR_APPROVAL" Then
attr.TextString = GFA
ElseIf attr.TagString = "GOOD_FOR_USE" Then
attr.TextString = GFU
ElseIf attr.TagString = "AS_BUILT" Then
attr.TextString = ASBUILT
'--------------Index_A-------------------------------------------------------
ElseIf DrawingTable.TextBox19.value = "A1" Then
If attr.TagString = "INDEX_A" Then
attr.TextString = IndA
ElseIf attr.TagString = "INDEX_A_DATE" Then
attr.TextString = IndADate
ElseIf attr.TagString = "INDEX_A_MODIFICATION_1" Then
attr.TextString = IndAmod1
ElseIf attr.TagString = "INDEX_A_MODIFICATION_2" Then
attr.TextString = IndAmod2
ElseIf attr.TagString = "INDEX_A_DESIGNED" Then
attr.TextString = IndAdesign
ElseIf attr.TagString = "INDEX_A_CHECKED" Then
attr.TextString = IndAcheck
ElseIf attr.TagString = "INDEX_A_CHECK_APPROV" Then
attr.TextString = IndAcheckApp
End If
End If
Next
Next
End If
Else
MsgBox "No blocks """ & blkName & """ found in current drawing!"
Exit Sub
End If
On Error Resume Next
ERRORHANDLER:
If Err.Description <> "" Then
Err.Clear
End If
Function FindBlocksOnAllLayouts2(dwg As AcadDocument, blkName As String) As AcadSelectionSet
Set FindBlocksOnAllLayouts2 = CreateSelectionSet(dwg, "blcks")
Dim gpCode(0 To 0) As Integer
Dim dataValue(0 To 0) As Variant
gpCode(0) = 0: dataValue(0) = "INSERT"
'gpCode(1) = 2: dataValue(1) = blkName
FindBlocksOnAllLayouts2.Select acSelectionSetAll, , , gpCode, dataValue
End Function
Function CreateSelectionSet(acDoc As AcadDocument, SSset As String) As AcadSelectionSet
On Error Resume Next
Set CreateSelectionSet = acDoc.SelectionSets(SSset)
If Err Then Set CreateSelectionSet = acDoc.SelectionSets.Add(SSset)
CreateSelectionSet.Clear
End Function