I have revised the code and no longer have the issue with "type mismatch".
Obviously, it's a simple program but I plan to build on it gradually.
Public acad As Object
Public doc As Object
Public ms As Object
Public ss As Object
Public ssnew As Object
Public Theatts As Variant
Public MsgBoxResp As Integer
Private Sub CommandButton1_Click()
UpdateAttrib 0, UserForm1.Txt1
End Sub
Private Sub UserForm_Initialize()
Dim BlkG(0) As Integer
Dim TheBlock(0) As Variant
Dim Pt1(0 To 2) As Double
Dim Pt2(0 To 2) As Double
'declare local variables
Set acad = GetObject(, "AutoCAD.Application")
'set reference to AutoCAD
Set doc = acad.ActiveDocument
'set reference to the drawing
Set ms = doc.ModelSpace
'set reference to model space
Set ssnew = doc.SelectionSets.Add("TBLK")
'create a selection set
Pt1(0) = 0: Pt1(1) = 0: Pt1(2) = 0
Pt2(0) = 3: Pt2(1) = 3: Pt2(2) = 0
'set up the array
BlkG(0) = 2
'group code 2 for block name
TheBlock(0) = "SV-PCS7"
'the name of the attribute block
ssnew.Select 5, Pt1, Pt2, BlkG, TheBlock
'get the block
If ssnew.Count >= 1 Then
'if the block is found
Theatts = ssnew.Item(0).GetAttributes
'get the attributes
UserForm1.Txt1.Text = UCase(LTrim(Theatts(0).TextString))
'get the title attribute
'clear any leading spaces and
'convert to uppercase
UserForm1.Txt1.Text = UCase(LTrim(Theatts(1).TextString))
UserForm1.Txt1.SetFocus
UserForm1.Txt1.SelStart = 0
UserForm1.Txt1.SelLength = Len(UserForm1.Txt1.Text)
'set the focus to the drawing title and highlight it
Else
'if no attribute title block is found
MsgBox "Sorry - No Material List Attributes....", vbCritical
'inform the user that there is no attribute title block
ThisDrawing.SelectionSets("TBLK").Delete
End
'end the application
End If
ThisDrawing.SelectionSets("TBLK").Delete
End Sub
'declare global variables
Sub UpdateAttrib(TagNumber As Integer, BTextString As String)
'This Sub Procedure tests the attribute data to check
'that is not a null value
If BTextString = "" Then
'if the attribute is empty
Theatts(TagNumber).TextString = ""
'put a '-' place holder
Else
'if it is not empty
Theatts(TagNumber).TextString = BTextString
'use the attribute value
End If
End Sub
Sub setupsv()
'name of function
UserForm1.show
'display the dialogue box
'UserForm1
End Sub