I have written some VBA code to reformat an EXCEL spread sheet into a WORD document. The document has three separate tables. Each table prints on a separate page. I want one table to print in landscape and the other two in portrait. The best I can do is to get all three tables in portrait or all three in landscape. It seems that the orientation of all the pages/tables corresponds to whatever is the last orientation setting regardless of previous settings. I want to be able to define a page, set the orientation, insert a table then insert the next page etc.

Here is (most of) the current code:

'Start Word and open the document template.
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Add

LTPlan = ""
r = 1: c = 0: TableCnt = 0
For i = 1 To 10
For j = 1 To 13
TableVals(i, j) = 0
Next j
Next i
For i = 1 To NumAtts
Nstr = Chr(10) + XAttendee(i).Fnm + " " + XAttendee(i).Snm
If i = 1 Then
'Insert a paragraph at the beginning of the document.
Set oPara1 = oDoc.Content.Paragraphs.Add
oPara1.Range.Text = "OOBS TABLE PLAN"
oPara1.Range.Font.Bold = True
oPara1.Range.Font.Name = XFont
oPara1.Range.Font.Size = 16
oPara1.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
oPara1.Format.SpaceAfter = 12 '12 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter
'Insert a 5 x 2 table, fill it with data and make the first row
Set oTable = oDoc.Tables.Add(oDoc.Bookmarks("\endofdoc").Range, 5, 2)
oTable.Range.ParagraphFormat.SpaceAfter = 1
End If
If r > 5 Then
'Insert a 5 x 2 table, fill it with data and make the first row
oPara1.Range.InsertBreak wdPageBreak
Set oTable = oDoc.Tables.Add(oDoc.Bookmarks("\endofdoc").Range, 5, 2)
oTable.Range.ParagraphFormat.SpaceAfter = 1
r = 1: c = 0
End If
If LTPlan <> XAttendee(i).TPlan Then
LTPlan = XAttendee(i).TPlan
Tstr = Chr(10) + "Table " + Chr(10) + LTPlan
TableCnt = TableCnt + 1
TableStr(TableCnt) = Tstr
c = c + 1
End If
Tstr = Tstr + Nstr

' accumulate menus selections for this table
For j = 1 To 13
TableVals(TableCnt, j) = TableVals(TableCnt, j) + XAttendee(i).MenuVal(j)
Next j

If c > 2 Then
r = r + 1
If r > 5 Then
MsgBox ("Too Many Tables (> 10)")
End If
c = 1
End If
oTable.cell(r, c).Range.Text = Tstr
oTable.cell(r, c).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
oTable.cell(r, c).Range.Font.Name = XFont
oTable.cell(r, c).Range.Font.Size = 10
oTable.cell(r, c).Range.Font.Bold = True
oTable.cell(r, c).Range.Font.Italic = False

Next i

ActiveDocument.PrintOut Range:=wdPrintCurrentPage

' insert page page after Table Plan to ensure Table Plan is output
oPara1.Range.InsertBreak wdPageBreak
oDoc.Range.Document.PageSetup.Orientation = wdOrientLandscape

'Insert a 10 x 14 table, fill it with data and make the first row
Set oTable = oDoc.Tables.Add(oDoc.Bookmarks("\endofdoc").Range, XMenuCnt + 1, TableCnt + 2)
oTable.Range.ParagraphFormat.SpaceAfter = 1
oPara1.Range.InsertBreak wdPageBreak


'Set column widths
For j = 1 To XMenuCnt + 1
oTable.cell(j, 1).Range.Cells.Width = 120
For k = 2 To TableCnt + 2
oTable.cell(j, k).Range.Cells.Width = 35
Next k
Next j

' Enter table number/letter in first row
FontSize = 6

For j = 1 To TableCnt + 1
If j = TableCnt + 1 Then oTable.cell(1, j + 1).Range.Text = Chr(10) + "Total" Else oTable.cell(1, j + 1).Range.Text = TableStr(j)
oTable.cell(1, j + 1).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
oTable.cell(1, j + 1).Range.Font.Name = XFont
oTable.cell(1, j + 1).Range.Font.Size = FontSize
oTable.cell(1, j + 1).Range.Font.Bold = True
oTable.cell(1, j + 1).Range.Font.Italic = False
Next j

For k = 1 To XMenuCnt
i = k + 1 'Enter menu choices in column 1
oTable.cell(i, 1).Range.Text = XmenuName(i)
oTable.cell(i, 1).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft
oTable.cell(i, 1).Range.Font.Name = XFont
oTable.cell(i, 1).Range.Font.Size = FontSize
oTable.cell(i, 1).Range.Font.Bold = True
oTable.cell(i, 1).Range.Font.Italic = False
XTmp = 0
For j = 1 To TableCnt 'Enter counts of choices by table
YTmp = TableVals(j, i - 1)
oTable.cell(i, j + 1).Range.Text = YTmp
XTmp = XTmp + YTmp
oTable.cell(i, j + 1).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
oTable.cell(i, j + 1).Range.Font.Name = XFont
oTable.cell(i, j + 1).Range.Font.Size = FontSize
oTable.cell(i, j + 1).Range.Font.Bold = True
oTable.cell(i, j + 1).Range.Font.Italic = False
Next j
j = TableCnt + 2
oTable.cell(i, j).Range.Text = XTmp
oTable.cell(i, j).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
oTable.cell(i, j).Range.Font.Name = XFont
oTable.cell(i, j).Range.Font.Size = FontSize
oTable.cell(i, j).Range.Font.Bold = True
oTable.cell(i, j).Range.Font.Italic = False
Next k

ActiveDocument.PrintOut Range:=wdPrintCurrentPage

' insert page page after Table Counts to ensure Table Counts are is output
oDoc.PageSetup.Orientation = wdOrientPortrait

r = 99: c = 0
For i = 1 To NumAtts
If r > 5 Then
'Insert a 5 x 2 table, fill it with data and make the first row
Set oTable = oDoc.Tables.Add(oDoc.Bookmarks("\endofdoc").Range, 5, 2)
oTable.Range.ParagraphFormat.SpaceAfter = 9
oPara1.Range.InsertBreak wdPageBreak
r = 1: c = 0
End If
c = c + 1
If c > 2 Then
r = r + 1
If r > 5 Then
Set oTable = oDoc.Tables.Add(oDoc.Bookmarks("\endofdoc").Range, 5, 2)
oTable.Range.ParagraphFormat.SpaceAfter = 9
oPara1.Range.InsertBreak wdPageBreak
r = 1
End If
c = 1
End If
oTable.cell(r, c).Range.Text = XAttendee(i).Xlabel
'MsgBox (Str(r) + " " + Str(c) + " " + Str(i) + " " + XAttendee(i).Xlabel)
oTable.cell(r, c).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
oTable.cell(r, c).Range.Font.Name = XFont
oTable.cell(r, c).Range.Font.Size = 10
oTable.cell(r, c).Range.Font.Bold = True
oTable.cell(r, c).Range.Font.Italic = False
Next i

ActiveDocument.PrintOut Range:=wdPrintCurrentPage

'Insert a paragraph at the end of the document.
'** \endofdoc is a predefined bookmark.
Set oPara2 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks("\endofdoc").Range)
oPara2.Range.Text = "END OF DATA"
oPara2.Format.SpaceAfter = 6
oPara2.Range.InsertParagraphAfter
CreateWordDoc = 0