Community
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
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.
Solved! Go to Solution.
Solved by Ray-Sync. Go to Solution.
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.
Can't find what you're looking for? Ask the community or share your knowledge.