Word Automation Problem in Vb.net

kr80

Member
Joined
May 31, 2005
Messages
9
Programming Experience
1-3
I am trying to create a Word File with two Columns. Vertical text in the fist and Horizontal text in the second column.I managed to display the vertical content correctly, but the Second columns just gets replaced or rewritten with the next appearing line.

My code :


VB.NET:
Dim WordApp As New Word.Application 
    Dim doc As New Word.Document 
    Dim oTable As Word.Table 

    If WordApp.Options.Overtype Then 
      WordApp.Options.Overtype = False 
    End If 

    doc = WordApp.Documents.Add() 
    oTable = doc.Tables.Add(doc.Range, 1, 2) 
    With WordApp.Selection 

'First column 
      oTable.Cell(1, 1).Range.Orientation = Word.WdTextOrientation.wdTextOrientationDownward 
      oTable.Cell(1, 1).Column.Width = 88 
      oTable.Cell(1, 1).Row.Height = 450 

      .TypeText(editSoftwareName.Text) 
      .TypeText(editVersion.Text) 

' Second Column 

      If WordApp.Options.Overtype Then 
        WordApp.Options.Overtype = False 
      End If 

      oTable.Cell(1, 2).Range.Orientation = Word.WdTextOrientation.wdTextOrientationHorizontal 
      oTable.Cell(1, 2).Column.Width = 450 
      oTable.Cell(1, 2).Row.Height = 450 

      oTable.Cell(1, 2).Range.Text() = editSoftwareName.Text 
      oTable.Cell(1, 2).Range.Text() =editVersion.Text 

    End With 
    doc.SaveAs("LabelPrintFile") 
    'doc.PrintOut() 
    doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges) 
    WordApp.Quit() 
    btnlprint.Enabled = False 
  End Sub
 
Back
Top