I believe I am creating the AxDbDocument, but I cannot seem to Save when changing a TagString. I've also tried dwg.Update with dwg.Save, but it didn't work.
With Application.FileDialog(msoFileDialogFilePicker)
If .Show <> 0 Then
OnStart
For Each File In .SelectedItems
If LCase(Right(File, 3)) = "dwg" Then
curRow = curRow + 1
Cells(curRow, 1).Value = Mid(File, InStrRev(File, "\") + 1)
Cells(curRow, 1).Font.Bold = True
Set dwg = acad.GetInterFaceObject("ObjectDBX.AxDbDocument.24")
dwg.Open File
Set pspace = dwg.PaperSpace
Set mspace = dwg.ModelSpace
Dim flag As Integer
flag = 0
Dim title As String
title = ""
'Loop through each element in paperspace
For Each elem In pspace
With elem
'Check if a block has been found and if it has attributes
If StrComp(.EntityName, "AcDbBlockReference", 1) = 0 Then
If .HasAttributes <> 0 And elem.Name = "SMECOborderSUB" Then
'MsgBox elem.Name
flag = 1
blkAttributes = .GetAttributes
'Loop through each attribute of the block
For i = LBound(blkAttributes) To UBound(blkAttributes)
'MyStr = blkAttributes(i).TagString
'MsgBox MyStr
If StrComp(blkAttributes(i).EntityName, "AcDbAttribute", 1) = 0 Then
'Check if a column has already been created for the tag
If Not dictAttr.Exists(blkAttributes(i).TagString) Then
dictAttr.Add blkAttributes(i).TagString, curCol
Cells(4, curCol).Value = blkAttributes(i).TagString
Cells(4, curCol).Font.Bold = True
curCol = curCol + 1
Else
'If the column has already been created then let's index it
MyStr = blkAttributes(i).TagString & n
blkAttributes(i).TagString = MyStr
blkAttributes(i).Update
dictAttr.Add MyStr, curCol
Cells(4, curCol).Value = MyStr
Cells(4, curCol).Font.Bold = True
curCol = curCol + 1
n = n + 1
End If
'Select Case blkAttributes(i).TagString
' Case "2-", "3-", "4-", "5-"
' title = title & blkAttributes(i).TextString & " "
'End Select
'Add value of tag
Cells(curRow, dictAttr(blkAttributes(i).TagString)).NumberFormat = "@"
Cells(curRow, dictAttr(blkAttributes(i).TagString)).Value = blkAttributes(i).TextString
End If
Next i
'curRow = curRow + 1
Exit For
End If
Else
'MyStr = elem.EntityName
'MsgBox MyStr
'Cells(curRow, 1).Value = elem.EntityName
'curRow = curRow + 1
End If
End With
Next elem
'check model space
'really should just create a function instead of copy/pasting it twice
If flag = 0 Then
For Each elem In mspace
With elem
'Check if a block has been found and if it has attributes
If StrComp(.EntityName, "AcDbBlockReference", 1) = 0 Then
If .HasAttributes And InStr(.Name, "CEII") <> 0 Then
flag = 1
blkAttributes = .GetAttributes
'Loop through each attribute of the block
For i = LBound(blkAttributes) To UBound(blkAttributes)
If StrComp(blkAttributes(i).EntityName, "AcDbAttribute", 1) = 0 Then
'Check if a column has already been created for the tag
If Not dictAttr.Exists(blkAttributes(i).TagString) Then
dictAttr.Add blkAttributes(i).TagString, curCol
Cells(4, curCol).Value = blkAttributes(i).TagString
Cells(4, curCol).Font.Bold = True
curCol = curCol + 1
End If
Select Case blkAttributes(i).TagString
Case "2-", "3-", "4-", "5-"
title = title & blkAttributes(i).TextString & " "
End Select
'Add value of tag
Cells(curRow, dictAttr(blkAttributes(i).TagString)).Value = blkAttributes(i).TextString
End If
Next i
Exit For
End If
End If
End With
Next elem
End If
'If Not dictAttr.Exists("FULL TITLE") Then
' dictAttr.Add "FULL TITLE", curCol
' Cells(4, curCol).Value = "FULL TITLE"
' Cells(4, curCol).Font.Bold = True
' curCol = curCol + 1
'End If
'Cells(curRow, dictAttr("FULL TITLE")).Value = RTrim(title)
If flag = 0 Then
MsgBox ("Could not find title block in drawing " & File)
curRow = curRow - 1
End If
End If
Next File
End If
End With