Microsoft Word Page Break

I am trying to insert a page break into a word document.

I have been trying to use InsertBreak to handle this, but I keep getting OLE Automation Errors no matter what I do, does anyone know the proper way to do a page break from XOJO in Mocrosoft Word?

What object are you applying the InsertBreak to?
Do you have a ‘selection’

Do you get the same problem with InsertNewPage?

I do have a ‘selection’.

I am not sure how I would use InsertNewPage to be honest.

Here is my code at present (still a work in progress obviously):

[code] app.ExcelWordRunning = True
MakeSheetIndex(True)

	Dim oword As wordapplication
	Dim odoc As WordDocument
	dim otable as WordTable
	dim oPara4 as WordParagraph
	dim oRng as WordRange
	dim WrdSel as WordSelection
	oword = New wordapplication
	oword.visible = True
	oDoc = oWord.Documents.Open("H:\\Templates\\Forms - Logo.dotx")
	oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\\endofdoc").Range, 2, 2)
	oTable.Rows.Item(1).Range.Font.Bold = True
	oTable.Rows.Item(1).Range.Font.Name = "Arial"
	oTable.Rows.Item(1).Range.Font.Size = 12
	oTable.Rows.Item(2).Range.Font.Bold = True
	oTable.Rows.Item(2).Range.Font.Name = "Arial"
	oTable.Rows.Item(2).Range.Font.Size = 12
	oTable.Range.ParagraphFormat.SpaceBefore = 24
	oTable.Cell(1, 1).Range.Text = "Transmittal"
	Dim Today as new date
	oTable.Cell(1, 2).Range.Text = "Date: " + str(Today.Month,"00") + "/" + str(Today.Day,"00") + "/" + Str(Today.Year,"0000")
	oTable.Cell(1, 2).Range.ParagraphFormat.Alignment = Office.wdAlignParagraphRight
	oTable.Cell(2, 1).Range.Text = "Delivered by "
	oPara4 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\\endofdoc").Range)
	oPara4.Range.InsertParagraphBefore()
	oPara4.Range.Text = ""
	oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\\endofdoc").Range, 6, 4)
	'MsgBox("0")
	'oTable.Columns.Item(1).SetWidth(37, Office.wdAdjustNone)
	'MsgBox("1")
	oTable.Range.ParagraphFormat.SpaceAfter = 6
	oTable.Cell(1, 1).Range.Text = "To:"
	otable.Cell(1, 2).Range.Text = SentTo
	oTable.Cell(1, 3).Range.Text = "Phone No.:"
	oTable.Cell(1, 4).Range.ParagraphFormat.Alignment = Office.wdAlignParagraphRight
	'oTable.Cell(1, 4).Range.Text = Phone.Text
	'oTable.Cell(1, 2).Range.Text = Company.Text
	oTable.Cell(1, 2).Range.Font.Bold = True
	'oTable.Columns.Item(2).SetWidth(200, Office.wdAdjustNone)
	'MsgBox("2")
	'oTable.Cell(2, 2).Range.Text = Address1.Text
	'If Address2.Text <> "" Then
	'oTable.Cell(2, 2).Range.Text = oTable.Cell(2, 2).Range.Text & Address2.Text
	'End If
	'oTable.Cell(2, 2).Range.Text = oTable.Cell(2, 2).Range.Text & City.Text & ", " & State.Text & "  " & Zip.Text
	oTable.Cell(3, 1).Range.Text = "Attn:"
	oTable.Cell(3, 2).Range.Text = SentTo
	oTable.Cell(4, 1).Range.Text = "Re:"
	'oTable.Cell(4, 2).Range.Text = pInfo(1).Titlecase
	oTable.Cell(4, 3).Range.Text = "Project No.:"
	'oTable.Cell(4, 4).Range.Text = pInfo(0).Uppercase
	oTable.Cell(4, 4).Range.ParagraphFormat.Alignment = Office.wdAlignParagraphRight
	oTable.Borders.Enable = True
	For r as integer = 1 To 6
			For c as integer = 1 To 4
					If r = 5 Then
							oTable.Cell(r, c).Range.Font.Size = 1
							oTable.Cell(r, c).Range.ParagraphFormat.LineSpacing = 1
							oTable.Cell(r, c).Range.Borders.InsideLineStyle = Office.wdLineStyleNone
							oTable.Cell(r, c).Range.Borders.OutsideLineStyle = Office.wdLineStyleNone
							oTable.Cell(r, c).Range.Font.Name = "Arial"
					Else
							oTable.Cell(r, c).Range.Font.Size = 12
							oTable.Cell(r, c).Range.ParagraphFormat.LineSpacing = 15
							oTable.Cell(r, c).Range.Borders.InsideLineStyle = Office.wdLineStyleNone
							oTable.Cell(r, c).Range.Borders.OutsideLineStyle = Office.wdLineStyleNone
							oTable.Cell(r, c).Range.Font.Name = "Arial"
					End If
			Next
	Next
	oTable.Rows.Item(1).Range.Borders(Office.wdBorderTop).LineStyle = Office.wdLineStyleSingle
	oTable.Rows.Item(1).Range.Borders(Office.wdBorderTop).LineWidth = Office.wdLineWidth225pt
	oTable.Rows.Item(4).Range.Borders(Office.wdBorderBottom).LineStyle = Office.wdLineStyleSingle
	oTable.Rows.Item(4).Range.Borders(Office.wdBorderBottom).LineWidth = Office.wdLineWidth225pt
	oTable.Cell(6, 1).Range.Text = "Description:"
	oTable.Cell(6, 2).Range.Text = Reason.Titlecase.trim + " Drawings"
	oTable.Cell(6, 2).Range.Font.Bold = True
	'oTable.Cell(6, 2).SetWidth(180, Office.wdAdjustNone)
	'MsgBox("3")
	'oTable.Cell(6, 1).SetWidth(80, Office.wdAdjustNone)
	'MsgBox("4")
	oTable.Range.End_ = True
	oDoc.Bookmarks.Item("\\endofdoc").Range.InsertParagraphAfter()
	oRng = oDoc.Bookmarks.Item("\\endofdoc").Range
	oPara4 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\\endofdoc").Range)
	oPara4.Range.Font.Size = 12
	oPara4.Range.Font.Name = "Arial"
	oPara4.Range.InsertParagraphBefore()
	'oRng.InsertAfter(ClientRequested.Text & ":")
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	dim txt as String = " set of "
	if Copies > 1 then
			txt = " sets of "
	end if
	dim discs as String
	dim shtcount as integer = 0
	while UBound(DiscCounts) >= 0
			dim tmp() as String = DiscCounts(0).Split("|")
			shtcount = shtcount + tmp(1).Val
			discs = discs.Append(tmp(1) + " " + tmp(0))
			DiscCounts.Remove(0)
	wend
	dim TotalSheets as Integer = shtcount * Copies
	dim TotalSqFt as Integer = TotalSheets * SqFtPerSheet
	oRng.InsertAfter("Please find enclosed " + Copies.ToText + txt + discs + " for " + Reason + ", for a total of " + TotalSheets.ToText + " sheets at " + SqFtPerSheet.ToText + "square feet per sheet, for a total of " + TotalSqFt.ToText + " square feet. Please refer to sheet index on additional pages for more details.")
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	oRng.InsertAfter("Should you require any further information, please contact " + App.FullName + ".")
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	oRng.InsertAfter("Regards,")
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	oRng.InsertAfter(app.FullName)
	oRng.InsertParagraphAfter()
	oRng.InsertAfter(app.JobTitle)
	oPara4.Format.SpaceAfter = 24
	oPara4.Range.InsertParagraphAfter()
	WrdSel = oWord.selection
	odoc.Content.InsertAfter chr(11) + chr(11)
	
	oWord.selection.endkey(6)
	oword.Selection.InsertBreak(7)
	'WrdSel.InsertBreak(Office.wdPageBreak)
	
	
	oWord.selection.endkey(6)
	odoc.Range.PasteExcelTable(False,False,False)
	book.Close
	excel.Quit
	excel = nil
	book = nil
	if FolderExists(TransmittalFolder) = False then
			TransmittalFolder.MakeFolder
	end if
	if FolderExists(TransmittalFolder) then
			odoc.SaveAs(TransmittalFolder.NativePath + str(Today.year,"0000") + "-" + str(Today.Month,"00") + "-" + str(Today.Day,"00") + "_Trans - " + sentto + ".docx")
			TransmittalFolder.Launch
	end if
	'odoc.Close
	'oword.Quit
	oword = nil
	odoc = nil
	app.ExcelWordRunning = False[/code]

I wonder - Why do you switch from oword to oDoc to WrdSel if you have one document on the go?

If oword.Selection.InsertBreak(7) is working, try

call oword.Selection.InsertBreak()

Honestly, the switch was simply trying a different way to see if it would work.

When I use call oword.Selection.InsertBreak()

I get there is more than one item with this name and it’s not clear to which this refers.

So probably the method has overrides
I notice you supplied a pagebreak type in your first code.

MS docs say there is a default value if not supplied, maybe not so much here. Give it a parameter

Ok, so I did manage to get insertnewpage working properly, but when I paste in the Excel Table, it overwrites the entire document. any ideas?

One possibility is If the entire Word document is selected, then pasting the table will paste the Excel table over the entire word document. A solution would be to move the cursor where you want the added table, select a single space and paste the document.

Ok, I got past that hurdle, now I have a different situation, the following lines used to work flawlessly with Word 2013, but seem to cause errors with Word 2016:

oTable.Columns.Item(2).SetWidth(200, Office.wdAdjustNone) oTable.Cell(6, 2).SetWidth(180, Office.wdAdjustNone)

I have also tried:

oTable.Columns.Item(2).SetWidth(200, Office.wdAdjustFirstColumn) oTable.Cell(6, 2).SetWidth(180, Office.wdAdjustFirstColumn)

No matter what, I get an OLE exception error, any ideas on how to fix these items? Right now I have them remarked out, but would like to get them working.

Hello Christopher,

I ran the following code on both Word 2013 and 2016 and it works with Xojo 2016 r4.1.

[code]Dim oWord as New WordApplication

oWord.Documents.Add
oWord.Visible = True

oWord.ActiveDocument.Tables.Add(oWord.Selection.Range,2,3)
oWord.ActiveDocument.Tables(1).Select_

oWord.ActiveDocument.Tables(1).Columns.Item(2).SetWidth(50, Office.wdAdjustNone)
oWord.ActiveDocument.Tables(1).Cell(1,1).SetWidth(180, Office.wdAdjustNone)[/code]

Without knowing your modified code, my guess is that oTable might be improperly referenced.

Here is the full code:

[code] app.ExcelWordRunning = True
MakeSheetIndex(True)

	Dim oword As wordapplication
	Dim odoc As WordDocument
	dim otable as WordTable
	dim oPara4 as WordParagraph
	dim oRng as WordRange
	dim WrdSel as WordSelection
	oword = New wordapplication
	oword.visible = True
	oDoc = oWord.Documents.Open("H:\\Templates\\Forms - Logo.dotx")
	oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\\endofdoc").Range, 2, 2)
	oTable.Rows.Item(1).Range.Font.Bold = True
	oTable.Rows.Item(1).Range.Font.Name = "Arial"
	oTable.Rows.Item(1).Range.Font.Size = 12
	oTable.Rows.Item(2).Range.Font.Bold = True
	oTable.Rows.Item(2).Range.Font.Name = "Arial"
	oTable.Rows.Item(2).Range.Font.Size = 12
	oTable.Range.ParagraphFormat.SpaceBefore = 24
	oTable.Cell(1, 1).Range.Text = "Transmittal"
	Dim Today as new date
	oTable.Cell(1, 2).Range.Text = "Date: " + str(Today.Month,"00") + "/" + str(Today.Day,"00") + "/" + Str(Today.Year,"0000")
	oTable.Cell(1, 2).Range.ParagraphFormat.Alignment = Office.wdAlignParagraphRight
	oTable.Cell(2, 1).Range.Text = "Delivered by "
	oPara4 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\\endofdoc").Range)
	oPara4.Range.InsertParagraphBefore()
	oPara4.Range.Text = ""
	oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\\endofdoc").Range, 6, 4)
	'MsgBox("0")
	oWord.ActiveDocument.Tables(1).Select_
	oWord.ActiveDocument.Tables(1).Columns.Item(1).SetWidth(37, Office.wdAdjustNone)
	'oTable.Cell(1, 1).SetWidth(37, Office.wdAdjustNone)
	'oTable.Columns.Item(1).SetWidth(37, Office.wdAdjustFirstColumn)
	'MsgBox("1")
	oTable.Range.ParagraphFormat.SpaceAfter = 6
	oTable.Cell(1, 1).Range.Text = "To:"
	otable.Cell(1, 2).Range.Text = SentTo
	oTable.Cell(1, 3).Range.Text = "Phone No.:"
	oTable.Cell(1, 4).Range.ParagraphFormat.Alignment = Office.wdAlignParagraphRight
	'oTable.Cell(1, 4).Range.Text = Phone.Text
	'oTable.Cell(1, 2).Range.Text = Company.Text
	oTable.Cell(1, 2).Range.Font.Bold = True
	'oTable.Cell(1, 2).SetWidth(200, Office.wdAdjustNone)
	oWord.ActiveDocument.Tables(1).Columns.Item(1).SetWidth(200, Office.wdAdjustNone)
	'oTable.Columns.Item(2).SetWidth(200, Office.wdAdjustFirstColumn)
	'MsgBox("2")
	'oTable.Cell(2, 2).Range.Text = Address1.Text
	'If Address2.Text <> "" Then
	'oTable.Cell(2, 2).Range.Text = oTable.Cell(2, 2).Range.Text & Address2.Text
	'End If
	'oTable.Cell(2, 2).Range.Text = oTable.Cell(2, 2).Range.Text & City.Text & ", " & State.Text & "  " & Zip.Text
	oTable.Cell(3, 1).Range.Text = "Attn:"
	oTable.Cell(3, 2).Range.Text = SentTo
	oTable.Cell(4, 1).Range.Text = "Re:"
	oTable.Cell(4, 2).Range.Text = pName.Text.Titlecase
	oTable.Cell(4, 3).Range.Text = "Project No.:"
	oTable.Cell(4, 4).Range.Text = pno.Text.Uppercase
	oTable.Cell(4, 4).Range.ParagraphFormat.Alignment = Office.wdAlignParagraphRight
	oTable.Borders.Enable = True
	For r as integer = 1 To 6
			For c as integer = 1 To 4
					If r = 5 Then
							oTable.Cell(r, c).Range.Font.Size = 1
							oTable.Cell(r, c).Range.ParagraphFormat.LineSpacing = 1
							oTable.Cell(r, c).Range.Borders.InsideLineStyle = Office.wdLineStyleNone
							oTable.Cell(r, c).Range.Borders.OutsideLineStyle = Office.wdLineStyleNone
							oTable.Cell(r, c).Range.Font.Name = "Arial"
					Else
							oTable.Cell(r, c).Range.Font.Size = 12
							oTable.Cell(r, c).Range.ParagraphFormat.LineSpacing = 15
							oTable.Cell(r, c).Range.Borders.InsideLineStyle = Office.wdLineStyleNone
							oTable.Cell(r, c).Range.Borders.OutsideLineStyle = Office.wdLineStyleNone
							oTable.Cell(r, c).Range.Font.Name = "Arial"
					End If
			Next
	Next
	oTable.Rows.Item(1).Range.Borders(Office.wdBorderTop).LineStyle = Office.wdLineStyleSingle
	oTable.Rows.Item(1).Range.Borders(Office.wdBorderTop).LineWidth = Office.wdLineWidth225pt
	oTable.Rows.Item(4).Range.Borders(Office.wdBorderBottom).LineStyle = Office.wdLineStyleSingle
	oTable.Rows.Item(4).Range.Borders(Office.wdBorderBottom).LineWidth = Office.wdLineWidth225pt
	oTable.Cell(6, 1).Range.Text = "Description:"
	oTable.Cell(6, 2).Range.Text = Reason.Titlecase.trim + " Drawings"
	oTable.Cell(6, 2).Range.Font.Bold = True
	oWord.ActiveDocument.Tables(1).Cell(6,2).SetWidth(180, Office.wdAdjustNone)
	'oTable.Cell(6, 2).SetWidth(180, Office.wdAdjustNone)
	'MsgBox("3")
	oWord.ActiveDocument.Tables(1).Cell(6,1).SetWidth(80, Office.wdAdjustNone)
	'oTable.Cell(6, 1).SetWidth(80, Office.wdAdjustNone)
	'MsgBox("4")
	oTable.Range.End_ = True
	oDoc.Bookmarks.Item("\\endofdoc").Range.InsertParagraphAfter()
	oRng = oDoc.Bookmarks.Item("\\endofdoc").Range
	oPara4 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\\endofdoc").Range)
	oPara4.Range.Font.Size = 12
	oPara4.Range.Font.Name = "Arial"
	oPara4.Range.InsertParagraphBefore()
	'oRng.InsertAfter(ClientRequested.Text & ":")
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	dim txt as String = " set of "
	if Copies > 1 then
			txt = " sets of "
	end if
	dim discs as String
	dim shtcount as integer = 0
	while UBound(DiscCounts) >= 0
			dim tmp() as String = DiscCounts(0).Split("|")
			shtcount = shtcount + tmp(1).Val
			if shtcount > 0 then
					if discs = "" then
							discs = tmp(1) + " " + tmp(0).Replace("ENERGY", "Title 24 Compliance Forms").Titlecase
					else
							if UBound(DiscCounts) > 0 then
									discs = discs + ", " + tmp(1) + " " + tmp(0).Titlecase
							else
									discs = discs + " & " + tmp(1) + " " + tmp(0).Titlecase
							end if
					end if
			end if
			DiscCounts.Remove(0)
	wend
	dim TotalSheets as Integer = shtcount * Copies
	dim TotalSqFt as Integer = TotalSheets * SqFtPerSheet
	oRng.InsertAfter("Please find enclosed " + Copies.ToText + txt + discs + " for " + Reason.TitleCase + " sheets, for a total of " + TotalSheets.ToText + " sheets at " + SqFtPerSheet.ToText + " square feet per sheet, for a total of " + TotalSqFt.ToText + " square feet. Please refer to sheet index on additional pages for more details.")
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	oRng.InsertAfter("Should you require any further information, please contact " + App.FullName + ".")
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	oRng.InsertAfter("Regards,")
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	oRng.InsertParagraphAfter()
	oRng.InsertAfter(app.FullName)
	oRng.InsertParagraphAfter()
	oRng.InsertAfter(app.JobTitle)
	oPara4.Format.SpaceAfter = 24
	oPara4.Range.InsertParagraphAfter()
	WrdSel = oWord.selection
	odoc.Content.InsertAfter chr(11) + chr(11)
	oWord.selection.endkey(6)
	oword.Selection.InsertNewPage
	oWord.selection.endkey(6)
	oword.Selection.InsertParagraphAfter()
	oword.Selection.Paste
	dim c as new Clipboard
	c.Text = ""
	book.Close
	excel.Quit
	excel = nil
	book = nil
	oword.Selection.homekey(6)
	if FolderExists(TransmittalFolder) = False then
			TransmittalFolder.MakeFolder
	end if
	if FolderExists(TransmittalFolder) then
			odoc.SaveAs(TransmittalFolder.NativePath + str(Today.year,"0000") + "-" + str(Today.Month,"00") + "-" + str(Today.Day,"00") + "_Trans - " + sentto + ".docx")
			TransmittalFolder.Launch
	end if
	oword = nil
	odoc = nil
	app.ExcelWordRunning = False[/code]

I tried incorporating your changes, as you can see and it still fails.

I am still unable to figure out where the problem is, any suggestions?

Have you tried Eugenes code only? What happens for your code except that it fails?

Hi Christopher,

If you happen to know the answer to Beatrix’s question, then this would be helpful. Is the issue a logical error, or the table isn’t quite right, or you are getting an error when running the program? This would be helpful to try and figure out the issue.

There seems to be some commented code and references to objects and files that I do not have. Below is modified code that seems to work - there is some code missing. One way to help find out the problem is to add your code one part-at-a-time and compile the code to make sure it runs correctly. Another way to debug is to comment out sections of code until the program works correctly up to that point. Then start adding portions of code until the error can be found.

[code]Dim oword As wordapplication
Dim odoc As WordDocument
dim otable as WordTable
dim oPara4 as WordParagraph
dim oRng as WordRange
dim WrdSel as WordSelection
oword = New wordapplication
oword.visible = True
oDoc = oWord.Documents.Add //
oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\endofdoc").Range, 2, 2)
oTable.Rows.Item(1).Range.Font.Bold = True
oTable.Rows.Item(1).Range.Font.Name = “Arial”
oTable.Rows.Item(1).Range.Font.Size = 12
oTable.Rows.Item(2).Range.Font.Bold = True
oTable.Rows.Item(2).Range.Font.Name = “Arial”
oTable.Rows.Item(2).Range.Font.Size = 12
oTable.Range.ParagraphFormat.SpaceBefore = 24
oTable.Cell(1, 1).Range.Text = “Transmittal”
Dim Today as new date
oTable.Cell(1, 2).Range.Text = “Date: " + str(Today.Month,“00”) + “/” + str(Today.Day,“00”) + “/” + Str(Today.Year,“0000”)
oTable.Cell(1, 2).Range.ParagraphFormat.Alignment = Office.wdAlignParagraphRight
oTable.Cell(2, 1).Range.Text = “Delivered by "
oPara4 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item(”\endofdoc”).Range)
oPara4.Range.InsertParagraphBefore()
oPara4.Range.Text = “”
oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\endofdoc").Range, 6, 4)

oWord.ActiveDocument.Tables(1).Select_
oWord.ActiveDocument.Tables(1).Columns.Item(1).SetWidth(37, Office.wdAdjustNone)
oTable.Range.ParagraphFormat.SpaceAfter = 6
oTable.Cell(1, 1).Range.Text = “To:”
otable.Cell(1, 2).Range.Text = “SentTo”
oTable.Cell(1, 3).Range.Text = “Phone No.:”
oTable.Cell(1, 4).Range.ParagraphFormat.Alignment = Office.wdAlignParagraphRight
oTable.Cell(1, 2).Range.Font.Bold = True

oWord.ActiveDocument.Tables(1).Columns.Item(1).SetWidth(200, Office.wdAdjustNone)
oTable.Cell(3, 1).Range.Text = “Attn:”
oTable.Cell(3, 2).Range.Text = “SentTo”
oTable.Cell(4, 1).Range.Text = “Re:”
oTable.Cell(4, 2).Range.Text = “pName.Text.Titlecase”
oTable.Cell(4, 3).Range.Text = “Project No.:”
oTable.Cell(4, 4).Range.Text = “pno.Text.Uppercase”
oTable.Cell(4, 4).Range.ParagraphFormat.Alignment = Office.wdAlignParagraphRight
oTable.Borders.Enable = True
For r as integer = 1 To 6
For c as integer = 1 To 4
If r = 5 Then
oTable.Cell(r, c).Range.Font.Size = 1
oTable.Cell(r, c).Range.ParagraphFormat.LineSpacing = 1
oTable.Cell(r, c).Range.Borders.InsideLineStyle = Office.wdLineStyleNone
oTable.Cell(r, c).Range.Borders.OutsideLineStyle = Office.wdLineStyleNone
oTable.Cell(r, c).Range.Font.Name = “Arial”
Else
oTable.Cell(r, c).Range.Font.Size = 12
oTable.Cell(r, c).Range.ParagraphFormat.LineSpacing = 15
oTable.Cell(r, c).Range.Borders.InsideLineStyle = Office.wdLineStyleNone
oTable.Cell(r, c).Range.Borders.OutsideLineStyle = Office.wdLineStyleNone
oTable.Cell(r, c).Range.Font.Name = “Arial”
End If
Next
Next
oTable.Rows.Item(1).Range.Borders(Office.wdBorderTop).LineStyle = Office.wdLineStyleSingle
oTable.Rows.Item(1).Range.Borders(Office.wdBorderTop).LineWidth = Office.wdLineWidth225pt
oTable.Rows.Item(4).Range.Borders(Office.wdBorderBottom).LineStyle = Office.wdLineStyleSingle
oTable.Rows.Item(4).Range.Borders(Office.wdBorderBottom).LineWidth = Office.wdLineWidth225pt
oTable.Cell(6, 1).Range.Text = “Description:”
oTable.Cell(6, 2).Range.Text = “Reason.Titlecase.trim + Drawings”
oTable.Cell(6, 2).Range.Font.Bold = True
oWord.ActiveDocument.Tables(1).Cell(6,2).SetWidth(180, Office.wdAdjustNone)
oWord.ActiveDocument.Tables(1).Cell(6,1).SetWidth(80, Office.wdAdjustNone)
oTable.Range.End_ = True
oDoc.Bookmarks.Item("\endofdoc").Range.InsertParagraphAfter()
oRng = oDoc.Bookmarks.Item("\endofdoc").Range
oPara4 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\endofdoc").Range)
oPara4.Range.Font.Size = 12
oPara4.Range.Font.Name = “Arial”
oPara4.Range.InsertParagraphBefore()
oRng.InsertParagraphAfter()
oRng.InsertParagraphAfter()
dim txt as String = " set of "

dim discs as String
dim shtcount as integer = 0

shtcount = shtcount + 1
if shtcount > 0 then
if discs = “” then
discs = “ENERGY”
else
discs = discs + “, a”
end if
end if
dim TotalSheets as Integer = 3 //a number
dim TotalSqFt as Integer = 5 //a number
oRng.InsertAfter("Please find enclosed ")
oRng.InsertParagraphAfter()
oRng.InsertParagraphAfter()
oRng.InsertAfter("Should you require any further information, please contact ") // + App.FullName + “.”)
oRng.InsertParagraphAfter()
oRng.InsertParagraphAfter()
oRng.InsertAfter(“Regards,”)
oRng.InsertParagraphAfter()
oRng.InsertParagraphAfter()
oRng.InsertParagraphAfter()
oRng.InsertParagraphAfter()
oRng.InsertAfter(“app.FullName”)
oRng.InsertParagraphAfter()
oRng.InsertAfter(“app.JobTitle”)
oPara4.Format.SpaceAfter = 24
oPara4.Range.InsertParagraphAfter()
WrdSel = oWord.selection
odoc.Content.InsertAfter chr(11) + chr(11)
oWord.selection.endkey(6)
oword.Selection.InsertNewPage
oWord.selection.endkey(6)
oword.Selection.InsertParagraphAfter()
dim c as new Clipboard
c.Text = “”
oword.Selection.homekey(6)
oword = nil
odoc = nil[/code]

Happy to help.