AndrewForrest
Programmer
Gooday,
I am using VS2005/VB to create a report in a word document format, my problem is that when I draw a line on page one it appears but lines drawn on page 2 + donot. some of the code is below - any Ideas??
Thanks.
Imports Microsoft.Office.Interop.Word
Imports Microsoft.Office.Core
Dim oWord As Microsoft.Office.Interop.Word.Application
Dim oDoc As Microsoft.Office.Interop.Word.Document
Dim oRng As Microsoft.Office.Interop.Word.Range
Dim oPara2 As Microsoft.Office.Interop.Word.Paragraph
private subPrint()
oWord = CType(CreateObject("Word.Application"), Application)
oDoc = oWord.Documents.Add
oDoc.PageSetup.Orientation = WdOrientation.wdOrientPortrait
oDoc.PageSetup.TopMargin = oWord.CentimetersToPoints(0.25)
oDoc.PageSetup.BottomMargin = oWord.CentimetersToPoints(0.25)
oDoc.PageSetup.LeftMargin = oWord.CentimetersToPoints(1)
oDoc.PageSetup.RightMargin = oWord.CentimetersToPoints(1)
oDoc.PageSetup.PageWidth = oWord.CentimetersToPoints(29.7)
oDoc.PageSetup.PageHeight = oWord.CentimetersToPoints(21)
oWord.Visible = True
For Each iRow In RProduct.Tables("IMLSTRX").Rows
If intPage > 0 Then
strErrMess = "Insert New Page "
oRng.Collapse(Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseEnd)
oRng.InsertBreak(Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak)
oRng.Collapse(Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseEnd)
End If
oPara2 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\endofdoc").Range)
With oPara2.Range
.Font.Underline = WdUnderline.wdUnderlineDouble
.Font.Bold = True
.Font.Name = sFont
.Font.Size = 16
strTxt = " "
strLn = " PACK NO "
If frmChemLable.optShop.Checked Then
.Text = strTxt & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & strLn & vbTab & vbTab & strPackNo & vbTab & vbTab & vbTab & " "
Else
.Text = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & strLn & vbTab & vbTab & vbTab & vbTab & vbTab & " "
End If
.InsertParagraphAfter()
End With
oRng = oDoc.Bookmarks.Item("\endofdoc").Range
PosV = oRng.End - 11
oDoc.Shapes.AddLine(542, PosV, 542, (PosV + 62.8))
cntImg += 1
oDoc.Shapes.Item(cntImg).Line.Weight = 1.5
oRng = oDoc.Bookmarks.Item("\endofdoc").Range
oRng.Collapse(Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseEnd)
oRng.Font.Size = 8
oRng.Text = vbCrLf
intpage+=1
next
end sub
"Don't worry about the world coming to an end today.
It’s already tomorrow in Australia." - Charles Schulz
I am using VS2005/VB to create a report in a word document format, my problem is that when I draw a line on page one it appears but lines drawn on page 2 + donot. some of the code is below - any Ideas??
Thanks.
Imports Microsoft.Office.Interop.Word
Imports Microsoft.Office.Core
Dim oWord As Microsoft.Office.Interop.Word.Application
Dim oDoc As Microsoft.Office.Interop.Word.Document
Dim oRng As Microsoft.Office.Interop.Word.Range
Dim oPara2 As Microsoft.Office.Interop.Word.Paragraph
private subPrint()
oWord = CType(CreateObject("Word.Application"), Application)
oDoc = oWord.Documents.Add
oDoc.PageSetup.Orientation = WdOrientation.wdOrientPortrait
oDoc.PageSetup.TopMargin = oWord.CentimetersToPoints(0.25)
oDoc.PageSetup.BottomMargin = oWord.CentimetersToPoints(0.25)
oDoc.PageSetup.LeftMargin = oWord.CentimetersToPoints(1)
oDoc.PageSetup.RightMargin = oWord.CentimetersToPoints(1)
oDoc.PageSetup.PageWidth = oWord.CentimetersToPoints(29.7)
oDoc.PageSetup.PageHeight = oWord.CentimetersToPoints(21)
oWord.Visible = True
For Each iRow In RProduct.Tables("IMLSTRX").Rows
If intPage > 0 Then
strErrMess = "Insert New Page "
oRng.Collapse(Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseEnd)
oRng.InsertBreak(Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak)
oRng.Collapse(Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseEnd)
End If
oPara2 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\endofdoc").Range)
With oPara2.Range
.Font.Underline = WdUnderline.wdUnderlineDouble
.Font.Bold = True
.Font.Name = sFont
.Font.Size = 16
strTxt = " "
strLn = " PACK NO "
If frmChemLable.optShop.Checked Then
.Text = strTxt & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & strLn & vbTab & vbTab & strPackNo & vbTab & vbTab & vbTab & " "
Else
.Text = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & strLn & vbTab & vbTab & vbTab & vbTab & vbTab & " "
End If
.InsertParagraphAfter()
End With
oRng = oDoc.Bookmarks.Item("\endofdoc").Range
PosV = oRng.End - 11
oDoc.Shapes.AddLine(542, PosV, 542, (PosV + 62.8))
cntImg += 1
oDoc.Shapes.Item(cntImg).Line.Weight = 1.5
oRng = oDoc.Bookmarks.Item("\endofdoc").Range
oRng.Collapse(Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseEnd)
oRng.Font.Size = 8
oRng.Text = vbCrLf
intpage+=1
next
end sub
"Don't worry about the world coming to an end today.
It’s already tomorrow in Australia." - Charles Schulz