Although Robert has a good method there, if you're already working in VBA for the rest of your program, there is a way to do it.
Code:
Public Sub AttachDWS()
Dim oDict As AcadDictionary, oXRec As AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
Dim ArraySize As Long, iCount As Long
Dim yourDws As String
Private Const TYPE_STRING = 1
yourDws = "X:\TEST.dws" 'You will want to pass this some other way, obviously.
Set oDict = ThisDrawing.Dictionaries("AcStStandard")
' Build array from the existing dictionary
' because Dict counts from 1, this adds a spot for the new record
ArraySize = oDict.Count
Set oXRec = oDict.AddXRecord(ArraySize)
ReDim XRecordDataType(0 To ArraySize) As Integer
ReDim XRecordData(0 To ArraySize) As Variant
' append your new data to the XRecord
XRecordDataType(ArraySize) = TYPE_STRING: XRecordData(ArraySize) = CStr(yourDws)
oXRec.SetXRecordData XRecordDataType, XRecordData
' take a look at it
ThisDrawing.SendCommand "._Standards "
End Sub
This appends to the existing list of standards files without replacing. It doesn't check for duplicates before attaching the .dws, so you'll want to do that. It's entirely possible someone has a more elegant way of doing this, but I'm not much of a VBA guy myself -- but I thought I'd contribute since I've been getting good advice around here lately.