Hi all,

I have a series of letters which I create in MS Word through .net com interop, the main content is fine as it flows down the page however at the very bottom of each page (well actually about 10cm up from the bottom) and about 6cm indented from the left I want to put a reference no, then on the same line about 6cm further on the reference no repeated.

Id id think I had this sussed but later found that if my address was a line longer or shorter it displaced my reference numbers. Any help please.

heres my code at the moment,
VB Code:
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Try
  3.             Dim wrdSelection As Word.Selection
  4.             Dim wrdMailMerge As Word.MailMerge
  5.             Dim wrdMergeFields As Word.MailMergeFields
  6.             Dim strToAddSaleNo
  7.             Dim oTable As Word.Table
  8.             Dim StrToAdd As String
  9.  
  10.             Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
  11.             ' Create an instance of Word  and make it visible.
  12.             wrdApp = CreateObject("Word.Application")
  13.             wrdApp.Visible = True
  14.  
  15.             ' Add a new document.
  16.  
  17.             wrdDoc = wrdApp.Documents.Add()
  18.             wrdDoc.Select()
  19.  
  20.             wrdSelection = wrdApp.Selection()
  21.             wrdMailMerge = wrdDoc.MailMerge()
  22.  
  23.             ' Create MailMerge Data file.
  24.             CreateMailMergeDataFile()
  25.             With wrdDoc.PageSetup
  26.                 .TopMargin = 90
  27.                 .LeftMargin = 90
  28.                 .RightMargin = 22
  29.                 .BottomMargin = 20
  30.  
  31.             End With
  32.             InsertLines(4)
  33.  
  34.             ' Insert merge data.
  35.             wrdSelection.ParagraphFormat.Alignment = _
  36.                         Word.WdParagraphAlignment.wdAlignParagraphLeft
  37.             wrdMergeFields = wrdMailMerge.Fields()
  38.             wrdMergeFields.Add(wrdSelection.Range, "Title")
  39.             wrdSelection.TypeText(" ")
  40.             wrdMergeFields.Add(wrdSelection.Range, "FirstName")
  41.             wrdSelection.TypeText(" ")
  42.             wrdMergeFields.Add(wrdSelection.Range, "Surname")
  43.             wrdSelection.TypeParagraph()
  44.             wrdMergeFields.Add(wrdSelection.Range, "Street")
  45.             wrdSelection.TypeParagraph()
  46.             wrdMergeFields.Add(wrdSelection.Range, "Village")
  47.             wrdSelection.TypeParagraph()
  48.             wrdMergeFields.Add(wrdSelection.Range, "Town")
  49.             wrdSelection.TypeParagraph()
  50.             wrdMergeFields.Add(wrdSelection.Range, "County")
  51.             wrdSelection.TypeParagraph()
  52.             wrdMergeFields.Add(wrdSelection.Range, "Postcode")
  53.  
  54.             '////Initial cod eto get to bottom of page///////
  55.             'InsertLines(32)
  56.             ''wrdSelection.Font.Bold = Word.Font
  57.             'wrdSelection.ParagraphFormat.LineSpacing = 7.5
  58.             'InsertLines(3)
  59.             'wrdSelection.ParagraphFormat.LineSpacing = 10
  60.             ''InsertLines(2)
  61.             'wrdSelection.Paragraphs.TabIndent(0.5)
  62.             'wrdSelection.TypeText("RCD")
  63.             ''wrdMergeFields.Add(wrdSelection.Range, "SaleNo")
  64.             ''wrdSelection.TypeText("                                                                                    RCD")
  65.  
  66.             'wrdMergeFields.Add(wrdSelection.Range, "SaleNo")
  67.             ' Go to the end of the document.
  68.             '////////////////////////////////////////////////////
  69.  
  70.             '///Failed attempt at using a table to arrange data layout ///////////
  71.             'oTable = wrdDoc.Tables.Add(wrdSelection.Range, NumRows:=2, _
  72.             '     NumColumns:=2)
  73.  
  74.             'With oTable
  75.             '    '    ' Set the column widths.
  76.             '    .Columns.Item(1).SetWidth(100, Word.WdRulerStyle.wdAdjustNone)
  77.             '    .Columns.Item(2).SetWidth(100, Word.WdRulerStyle.wdAdjustNone)
  78.             '    .Rows.Item(1).SetHeight(20, Word.WdRowHeightRule.wdRowHeightExactly)
  79.             '    .Rows.Item(2).SetHeight(40, Word.WdRowHeightRule.wdRowHeightExactly)
  80.             '    '    ' Set the shading on the first row to light gray.
  81.             '        .Rows.Item(1).Cells.Shading.BackgroundPatternColorIndex = _
  82.             '         Word.WdColorIndex.wdAuto
  83.             '    ' Bold the first row.
  84.             '    .Rows.Item(1).Range.Bold = False
  85.             '    ' Center the text in Cell (1,1).
  86.             '        .Cell(1, 1).Range.Paragraphs.Alignment = _
  87.             '        Word.WdParagraphAlignment.wdAlignParagraphRight
  88.  
  89.             '    ' Fill each row of the table with data.
  90.             '    .Cell(1, 2).Range.Paragraphs.Alignment = _
  91.             '                  Word.WdParagraphAlignment.wdAlignParagraphRight
  92.  
  93.  
  94.             '    '.Cell(1, 1).Range.InsertAfter(wrdSelection.Range, "SaleNo")
  95.             '    '.Cell(1, 2).Range.InsertAfter(wrdMergeFields.Add(wrdSelection.Range, "SaleNo"))
  96.             'End With
  97.             '////////////////////////////////////////////////////////////////////
  98.             '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  99.  
  100.             ' Perform mail merge.
  101.             wrdMailMerge.Destination = _
  102.                        Word.WdMailMergeDestination.wdSendToNewDocument
  103.             wrdMailMerge.Execute(False)
  104.  
  105.             ' Close the original form document.
  106.             wrdDoc.Saved = True
  107.             wrdDoc.Close(False)
  108.  
  109.             ' Release References.
  110.             wrdSelection = Nothing
  111.             wrdMailMerge = Nothing
  112.             wrdMergeFields = Nothing
  113.             wrdDoc = Nothing
  114.             wrdApp = Nothing
  115.  
  116.             ' Clean up temp file.
  117.             System.IO.File.Delete("C:\DataDoc.doc")
  118.         Catch ex As Exception
  119.             MsgBox(ex.ToString & " Contact IT on x5005 Now ", MsgBoxStyle.OKOnly, "Error")
  120.         End Try
  121.         Me.Cursor = System.Windows.Forms.Cursors.Default
  122.     End Sub