Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit Existing Text with given handle

Status
Not open for further replies.

gnasher

IS-IT--Management
Jan 16, 2004
11
GB
I am fairly new to AutoCAD VBA, so please bear with me.

I have 4 / 5 existing lines of text (seperate AcadText entities, each of which I know the handles for) and would like to programatically change the text entry for each.

How can I refer to these select each entity with in VBA and change the text?

for example entity 679A says "Version 1.2" and I want to change to "Version 1.3"

Sounds so so simple, although I have just wasted an hour looking for examples on how to do this
 
There is a function called HandleToObject that will return the acad object entity.

something like this:

Dim T as AcadText
Set T = ThisDrawing.HandleToObject("2B")

you should trap any errors, or set T to a generic AcadObject then evaluate to make sure it is type AcadText.

Good Luck,

Scott
 
OK, so far so good, I now have a tempObject refering to
the existing text object:

(strHandle is sent to this function from elsewhere)

Dim tempObj As AcadObject
Set tempObj = ThisDrawing.HandleToObject(strHandle)

But how specifically can I now change the text contained in that object? Say from "Version 1.2" to "Version 1.3"

I want to change the information without loosing the handle

Thanks in advance, as you can appreciate, I am very new to ACAD vba
 
Dim tempObj As AcadObject
Dim objAcadText as AcadText

Set tempObj = ThisDrawing.HandleToObject(strHandle)
If TypeOf tempObj is AcadText then
Set objAcadText = tempObj
objAcadText.TextString = "Version 2"
objAcadText.Update
End If

Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top