Tablas de word
Publicado por Deivid (2 intervenciones) el 24/06/2007 22:22:02
Hola a todos y gracias por anticipado por si me solucionais mi problema.
Yo creo una tabla de Word desde VB mediante:
ActiveDocument.Table.Add Range:=Selection.Range, NumRows:=1, NumColumns:=2
y al cerrar word y volver a ejecutar el comando no me crea los bordes de la tabla solo me pone en una linea los valores que yo tengo en la tabla.
¿Como puedo solucionar esto?
Aqui pongo todo el codigo por si no me explicado bien.
Espero que me deis alguna solucion porque soy novato en programacion y lo necesito para un proyecto
Private Sub Command1_Click()
Dim docdeword As Object
Dim objword As Object
Dim ruta As String
On Error Resume Next
Set objword = GetObject(, "Word.Application")
If Err.Number = 429 Then
Err.Clear
Set objword = CreateObject("Word.Application")
End If
ruta = App.Path & "\test1.doc"
Set docdeword = objword.Documents.Open(ruta)
objword.Visible = True
With objword.Selection
.Tables.Add Range:=Selection.Range, numrows:=1, numcolumns:=2
.Tables(1).Rows.Add
.Tables(1).Rows(1).Select
.Font.Bold = True
.Tables(1).Cell(1, 1).Select
.TypeText "Marca"
.Tables(1).Cell(2, 1).Select
.TypeText "Modelo"
.Tables(1).Rows.Add
.Tables(1).Cell(3, 1).Select
.TypeText "Color"
.Tables(1).Rows.Add
.Tables(1).Cell(4, 1).Select
.TypeText "Año"
.Tables(1).Rows.Add
.Tables(1).Cell(5, 1).Select
.TypeText "Puertas"
.Tables(1).Rows.Add
.Tables(1).Cell(6, 1).Select
.TypeText "Patente"
.Tables(1).Cell(1, 2).Select
.TypeText "Chrevrolet"
.Tables(1).Cell(2, 2).Select
.TypeText "Cavalier"
.Tables(1).Cell(3, 2).Select
.TypeText "Rojo"
.Tables(1).Cell(4, 2).Select
.TypeText "2000"
.Tables(1).Cell(5, 2).Select
.TypeText "4"
.Tables(1).Cell(6, 2).Select
.TypeText "DFGT56"
End With
Set objword = Nothing
Set docdeword = Nothing
End Sub
Yo creo una tabla de Word desde VB mediante:
ActiveDocument.Table.Add Range:=Selection.Range, NumRows:=1, NumColumns:=2
y al cerrar word y volver a ejecutar el comando no me crea los bordes de la tabla solo me pone en una linea los valores que yo tengo en la tabla.
¿Como puedo solucionar esto?
Aqui pongo todo el codigo por si no me explicado bien.
Espero que me deis alguna solucion porque soy novato en programacion y lo necesito para un proyecto
Private Sub Command1_Click()
Dim docdeword As Object
Dim objword As Object
Dim ruta As String
On Error Resume Next
Set objword = GetObject(, "Word.Application")
If Err.Number = 429 Then
Err.Clear
Set objword = CreateObject("Word.Application")
End If
ruta = App.Path & "\test1.doc"
Set docdeword = objword.Documents.Open(ruta)
objword.Visible = True
With objword.Selection
.Tables.Add Range:=Selection.Range, numrows:=1, numcolumns:=2
.Tables(1).Rows.Add
.Tables(1).Rows(1).Select
.Font.Bold = True
.Tables(1).Cell(1, 1).Select
.TypeText "Marca"
.Tables(1).Cell(2, 1).Select
.TypeText "Modelo"
.Tables(1).Rows.Add
.Tables(1).Cell(3, 1).Select
.TypeText "Color"
.Tables(1).Rows.Add
.Tables(1).Cell(4, 1).Select
.TypeText "Año"
.Tables(1).Rows.Add
.Tables(1).Cell(5, 1).Select
.TypeText "Puertas"
.Tables(1).Rows.Add
.Tables(1).Cell(6, 1).Select
.TypeText "Patente"
.Tables(1).Cell(1, 2).Select
.TypeText "Chrevrolet"
.Tables(1).Cell(2, 2).Select
.TypeText "Cavalier"
.Tables(1).Cell(3, 2).Select
.TypeText "Rojo"
.Tables(1).Cell(4, 2).Select
.TypeText "2000"
.Tables(1).Cell(5, 2).Select
.TypeText "4"
.Tables(1).Cell(6, 2).Select
.TypeText "DFGT56"
End With
Set objword = Nothing
Set docdeword = Nothing
End Sub
Valora esta pregunta


0