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

PASS TEXT TO TABLES

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Ray-Sync
311 Views, 2 Replies

PASS TEXT TO TABLES

Private Sub CommandButton1_Click()

Dim WB As Word.Document
Dim WS As Word.Table
Dim DIREC As String
Dim tTable1 As AcadTable
Dim tPickedPnt As Variant
Dim tRow, tCol As Long

DIREC = TextBox2

Set WB = Word.Documents.Open(DIREC)

Me.Hide
On Error Resume Next
Call ThisDrawing.Utility.GetEntity(tTable1, tPickedPnt, "Select Source-Table: ")


For tRow = 0 To tTable1.Rows - 1
For tCol = 0 To tTable1.Columns - 1
Dim tVal As Variant: tVal = tTable1.GetValue(tRow, tCol, 0)
Next
Next

Set WS = WB.Tables.Add(Range:=Selection.Range, NumRows:=tRow, NumColumns:=tCol, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitContent)


WB.Close

MsgBox "¡Listo!"
Me.show

jefer_ing_0-1665119848487.png

jefer_ing_1-1665119888460.png

jefer_ing_2-1665119920863.png

Hello, this code allows me to pass tables from autocad to word but the texts are not passed, can someone help me please?


End Sub

 

Moderator: Please use the code window by clicking on the </> button.

jefferson
2 REPLIES 2
Message 2 of 3
Ray-Sync
in reply to: Ray-Sync

Este código te permitirá pasar tablas de autocad a word. SALUDOS.

 

Private Sub CommandButton1_Click()

Dim WB As Word.Document
Dim WS As Word.Table
Dim DIREC As String
Dim tTable1 As AcadTable
Dim tPickedPnt As Variant
Dim tRow, tCol As Long
Dim tVal As Variant

DIREC = TextBox2

Set WB = Word.Documents.Open(DIREC)

Me.Hide
On Error Resume Next
Call ThisDrawing.Utility.GetEntity(tTable1, tPickedPnt, "Select Source-Table: ")

Set WS = WB.Tables.Add(Range:=Selection.Range, NumRows:=tTable1.Rows+1, NumColumns:=tTable1.Columns+1, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitContent)

For tRow = 0 To tTable1.Rows
For tCol = 0 To tTable1.Columns
tVal = tTable1.GetValue(tRow, tCol, 0)
With WB.Tables(1).Cell(Row:=tRow + 1, Column:=tCol + 1).Range
.InsertAfter Text:=tVal
End With

Next tCol
Next tRow

WB.Close

MsgBox "¡Listo!"
Me.show

End Sub

 

 

Moderator: Please post your code into the code window by using the </> button.

jefferson
Message 3 of 3
Ray-Sync
in reply to: Ray-Sync

great, but how do I go about selecting multiple tables?
jefferson

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report