Visual Basic - Tablas de word desde VB6

Life is soft - evento anual de software empresarial
 
Vista:

Tablas de word desde VB6

Publicado por Deivid (2 intervenciones) el 20/06/2007 11:41:38
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
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder