Object word and vb6

0

I need to create a word document from vb6. I do not use the library reference office 11.0, so create objects. I have achieved the functionality, but I need the last paragraph to be centered horizontally, I have not found the form ...

Dim oWord As Object
Dim oDoc As Object
Dim otable As Object
Dim oPara2 As Object

    Dim iRow As Integer
    Set oWord = CreateObject("Word.Application")
    
    oWord.Options.ReplaceSelection = False
    Set oDoc = oWord.Documents.Add("N:\APP\CUMPLES\IMAGENES\basecumple5.dot")
    
    
    With oDoc.PageSetup
        .TopMargin = 80
        .LeftMargin = 85
        .BottomMargin = -20
    End With

    With poOraDynaset
        oDoc.InlineShapes.AddPicture FileName:="N:\APP\CUMPLES\IMAGENES\Titulo_" & Format(CStr(.Fields("FECHA_NACIMIENTO")), "mm") & ".gif"
        
        Set otable = oDoc.Tables.Add(oDoc.Bookmarks("\endofdoc").Range, .RecordCount, 3)
        If Not .RecordCount = 0 Then .MoveFirst
        Do Until .EOF
            iRow = iRow + 1
            otable.Cell(iRow, 1).Range.Text = MyCapitalize(CStr(.Fields("NOMBRE_COMPLETO")))
            otable.Cell(iRow, 2).Range.Text = CStr(.Fields("SECTOR"))
            otable.Cell(iRow, 3).Range.Text = Format(CStr(.Fields("FECHA_NACIMIENTO")), "dd/mmm")
            .MoveNext
        Loop
        
        Set oPara2 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks("\endofdoc").Range)
        oPara2.Range.Text = "MUCHAS FELICIDADES !"
        oPara2.ParagraphFormat.Alignment = wdAlignParagraphCenter ( <==== ESTO ME DA ERROR !!!! )
        oPara2.Range.Font.Size = 24
        oPara2.Format.SpaceBefore = 26
        oPara2.Range.InsertParagraphAfter

    End With

    On Local Error Resume Next
    
    otable.Columns(1).Width = 200
    otable.Columns(2).Width = 200
    otable.Columns(3).Width = 50
    otable.AutoFormat wdTableFormatGrid2, False, False, True, False, False, False, True, True, False
    oDoc.SaveAs "c:\windows\escritorio\Cumpleanios_" & Me.cmbMes.Text
    
    oWord.Visible = True

Set oWord = Nothing
Set oDoc = Nothing
Set otable = Nothing
Set oPara2 = Nothing


Uso Word 2003 ... Gracias 

I will appreciate your help !!!

    
asked by look68 13.03.2018 в 20:44
source

0 answers