VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Extract Text string from Field

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
539 Views, 5 Replies

Extract Text string from Field

I have learned how to create a field in VB using the Object Id, but I am struggling with how to extract the string itself from a field, place it into the clipboard, to be copied into another application (Excel). Thank you, Dan
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Use the TextString property to get what was evaluated. If there is other text besides the field, use the standard string manipulation functions (e.g. InStr) to extract the field info from the TexString. -- ---- Ed ---- "Dan" wrote in message news:41586a3f_3@newsprd01... > I have learned how to create a field in VB using the Object Id, but I am > struggling with how to extract the string itself from a field, place it into > the clipboard, to be copied into another application (Excel). > > > Thank you, > Dan > >
Message 3 of 6
Anonymous
in reply to: Anonymous

I understand how to truncate text to get what I want from the text string, but I have not figured out how to get the string from the field yet. I know how to get the field expression. I must be overlooking something: Sub CaptureFieldText() ' Create the selection set Dim ssetObj As AcadSelectionSet Dim point(0 To 2) As Double Dim fText As AcadText ' Not sure if this is the right object for the field Dim sysVarName As String Dim sysVarData As String sysVarName = "CTAB" sysVarData = "Model" ThisDrawing.SetVariable sysVarName, sysVarData Set ssetObj = ThisDrawing.SelectionSets.Add("capField") point(0) = -100: point(1) = 525.221859: point(2) = 0 ssetObj.SelectAtPoint point For Each fText In ssetObj 'Here is where I wanted to place code to extract string from field Next fText ThisDrawing.SelectionSets.Item("capField").Delete Set Layout = Nothing Set fText = Nothing End Sub Any help is appreciated. I am sure there are better habits, and coding could be optimized, flame awway. I am still very new at this, Thanks, Dan "Ed Jobe" wrote in message news:415878f2$1_1@newsprd01... > Use the TextString property to get what was evaluated. If there is other > text besides the field, use the standard string manipulation functions (e.g. > InStr) to extract the field info from the TexString. > > -- > ---- > Ed > ---- > "Dan" wrote in message > news:41586a3f_3@newsprd01... > > I have learned how to create a field in VB using the Object Id, but I am > > struggling with how to extract the string itself from a field, place it > into > > the clipboard, to be copied into another application (Excel). > > > > > > Thank you, > > Dan > > > > > >
Message 4 of 6
Anonymous
in reply to: Anonymous

Figured it out, Thanks. AcadEntity works with FIELD. Thats what I was looking for. Got my code working now. Have a great week, Dan "Dan" wrote in message news:415982b6$1_2@newsprd01... > I understand how to truncate text to get what I want from the text string, > but I have not figured out how to get the string from the field yet. I know > how to get the field expression. > > I must be overlooking something: > > Sub CaptureFieldText() > > ' Create the selection set > Dim ssetObj As AcadSelectionSet > Dim point(0 To 2) As Double > Dim fText As AcadText ' Not > sure if this is the right object for the field > Dim sysVarName As String > Dim sysVarData As String > sysVarName = "CTAB" > sysVarData = "Model" > ThisDrawing.SetVariable sysVarName, sysVarData > Set ssetObj = ThisDrawing.SelectionSets.Add("capField") > point(0) = -100: point(1) = 525.221859: point(2) = 0 > ssetObj.SelectAtPoint point > For Each fText In ssetObj > > 'Here is where I wanted to place code to extract string from field > > Next fText > ThisDrawing.SelectionSets.Item("capField").Delete > Set Layout = Nothing > Set fText = Nothing > End Sub > > Any help is appreciated. I am sure there are better habits, and coding could > be optimized, flame awway. > I am still very new at this, > > Thanks, > Dan > > "Ed Jobe" wrote in message > news:415878f2$1_1@newsprd01... > > Use the TextString property to get what was evaluated. If there is other > > text besides the field, use the standard string manipulation functions > (e.g. > > InStr) to extract the field info from the TexString. > > > > -- > > ---- > > Ed > > ---- > > "Dan" wrote in message > > news:41586a3f_3@newsprd01... > > > I have learned how to create a field in VB using the Object Id, but I am > > > struggling with how to extract the string itself from a field, place it > > into > > > the clipboard, to be copied into another application (Excel). > > > > > > > > > Thank you, > > > Dan > > > > > > > > > > > >
Message 5 of 6
leeraybone
in reply to: Anonymous

I am too struggling to extract the string form the field could you please advise on how you accomplished this.

Thanks in Advance

Lee
Message 6 of 6
danranderson327
in reply to: Anonymous

Well Lee,
Thinking back, it should be something as simple as the following:

{code}
Sub FindFieldTextString()
Dim entText As AcadEntity
Dim Pt As Variant

ThisDrawing.Utility.GetEntity entText, Pt, vbCr & "Select text entity:"
If TypeOf entText Is AcadText Or TypeOf entText Is AcadMText Then
MsgBox entText.TextString
End If

End Sub
{code}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost