I am trying to set the margins on a word document where I have pasted a table from excel. However, after the macro runs and I open the document to inspect it, the margins are all at 0" instead of what I specified. This puts the table out of the print area. I want all of the margins and the gutter to be 0.25". The gutter position and orientation are working just fine.
Dim oWd As Word.Application, oWdoc As Word.Document, oRng As Word.Range
.
. (Determining the size of and copying the excel Table)
.
Set oWd = CreateObject("Word.Application")
Set oWdoc = oWd.Documents.Add
Set oRng = oWdoc.Range
'Copy and paste the spreadsheet onto the document
oWdoc.Sections(1).Range.Paste
With oWdoc.Application.Selection.Tables(1).Rows
.LeftIndent = 0
.Alignment = wdAlignRowCenter
End With
'Document Page Setup
With oWdoc.PageSetup
.Gutter = 0.25
.GutterPos = wdGutterPosTop
.Orientation = wdOrientLandscape
.BottomMargin = 0.25
.TopMargin = 0.25
.LeftMargin = 0.25
.RightMargin = 0.25
.VerticalAlignment = wdAlignVerticalTop
End With
'Close out the document
oWdoc.SaveAs ("e:/WordTrial1.doc")
oWdoc.Close
oWd.Quit
Set oWdoc = Nothing
Set oWd = Nothing
Dim oWd As Word.Application, oWdoc As Word.Document, oRng As Word.Range
.
. (Determining the size of and copying the excel Table)
.
Set oWd = CreateObject("Word.Application")
Set oWdoc = oWd.Documents.Add
Set oRng = oWdoc.Range
'Copy and paste the spreadsheet onto the document
oWdoc.Sections(1).Range.Paste
With oWdoc.Application.Selection.Tables(1).Rows
.LeftIndent = 0
.Alignment = wdAlignRowCenter
End With
'Document Page Setup
With oWdoc.PageSetup
.Gutter = 0.25
.GutterPos = wdGutterPosTop
.Orientation = wdOrientLandscape
.BottomMargin = 0.25
.TopMargin = 0.25
.LeftMargin = 0.25
.RightMargin = 0.25
.VerticalAlignment = wdAlignVerticalTop
End With
'Close out the document
oWdoc.SaveAs ("e:/WordTrial1.doc")
oWdoc.Close
oWd.Quit
Set oWdoc = Nothing
Set oWd = Nothing