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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit Autocad text from Excel?

Status
Not open for further replies.

Ferris98

Programmer
Dec 16, 2002
4
US
I am trying to replace text in autocad with text from excel. How can this be accomplished? Currently I am accessing the file with the following macro, but am unsure how to complete the task...

' AutoCad Macro
' Macro recorded 12/10/02 by Fred G. Landry
'
'
Sub AutoCad()
Dim Response
Set fs = Application.FileSearch
With fs
.LookIn = "C:\STANDARDS"
.SearchSubFolders = True
.Filename = "AutoBom.dwg"
If .Execute() > 0 Then
ActiveWorkbook.FollowHyperlink Address:="C:\STANDARDS\AutoBom.dwg", _
NewWindow:=True
ActivateWindow = 1
Else
MsgBox "Autocad File Not Found"

End If
End With
End Sub
 
You will probably need to create a selection set object, then create a selection set of text (or some specific text). Toggle through the text and and when you find what you are looking for then set the textobject string to what you want. Is this too generic or were you looking for something written?
 
Something written would help, but thanks for the feedback. I'll give it a shot. Thanks!!!!
 
This is from the VBDESIGN.net site. A great place to start.

Public Function TextSelSet() As AcadSelectionSet
Dim objSelSet As AcadSelectionSet
Dim objSelCol As AcadSelectionSets
Dim intType(3) As Integer
Dim varData(3) As Variant
On Error GoTo Err_Control
Set objSelCol = ThisDrawing.SelectionSets
For Each objSelSet In objSelCol
If objSelSet.Name = "textsel" Then
objSelCol.Item("textsel").Delete
Exit For
End If
Next
Set objSelSet = objSelCol.Add("textsel")
intType(0) = -4
varData(0) = &quot;<OR&quot;
intType(1) = 0
varData(1) = &quot;TEXT&quot;
intType(2) = 0
varData(2) = &quot;MTEXT&quot;
intType(3) = -4
varData(3) = &quot;OR>&quot;
objSelSet.SelectOnScreen intType, varData
Set TextSelSet = objSelSet
Err_Control:
Select Case Err.Number
'additional cases here
Case Else
MsgBox Err.Description
Resume Exit_Here
End Select
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top