robertsmith28
asked on
Word Automation
I'm using Excel '97 and trying to produce a report in Word '97. I've created a table using the following code but I want the table itself to be aligned to the right-hand side of the page and for the right margin to be smaller than the default - how can I acheiev this? Any comments greatly appreciated:
Dim wordapp As Word.Application
Dim WordDoc As Word.Document
Set wordapp = CreateObject("Word.Applica tion")
Dim mytable As Word.Table
With wordapp
.ScreenUpdating = False
.Visible = True
.WindowState = wdWindowStateMaximize
.Documents.Add
Set WordDoc = .ActiveDocument
End With
Set mytable = WordDoc.Tables.Add(myRange , 6, 1)
With mytable
.Cell(1, 1).Range.InsertAfter "Network Transport Monthly Report"
.Cell(1, 1).Shading.BackgroundPatte rnColorInd ex = wdBlack
.Cell(1, 1).Range.Font.ColorIndex = wdWhite
.Cell(1, 1).Range.Font.Name = "Arial"
.Cell(1, 1).Range.Font.Size = 14
.Cell(1, 1).Range.Font.Bold = True
.Columns.Width = 310
.Rows(1).Height = 20
.Rows(1).Alignment = wdAlignRowLeft
.Rows(1).Cells.VerticalAli gnment = wdCellAlignVerticalBottom
End With
Dim wordapp As Word.Application
Dim WordDoc As Word.Document
Set wordapp = CreateObject("Word.Applica
Dim mytable As Word.Table
With wordapp
.ScreenUpdating = False
.Visible = True
.WindowState = wdWindowStateMaximize
.Documents.Add
Set WordDoc = .ActiveDocument
End With
Set mytable = WordDoc.Tables.Add(myRange
With mytable
.Cell(1, 1).Range.InsertAfter "Network Transport Monthly Report"
.Cell(1, 1).Shading.BackgroundPatte
.Cell(1, 1).Range.Font.ColorIndex = wdWhite
.Cell(1, 1).Range.Font.Name = "Arial"
.Cell(1, 1).Range.Font.Size = 14
.Cell(1, 1).Range.Font.Bold = True
.Columns.Width = 310
.Rows(1).Height = 20
.Rows(1).Alignment = wdAlignRowLeft
.Rows(1).Cells.VerticalAli
End With
ASKER
Thanks Datrias,
How do I indicate that my table is the paragraph to be right-aligned?
Sorry, this is the first time I've used Word Automation and its confusing for me...
How do I indicate that my table is the paragraph to be right-aligned?
Sorry, this is the first time I've used Word Automation and its confusing for me...
ASKER
I tried adding:
Set mytable = WordDoc.Tables.Add(myRange , 6, 1)
mytable.Select
Selection.ParagraphFormat. Alignment = wdAlignParagraphRight
but I get an error message stating 'Object does not suppport this property or method'. Any ideas what I'm doing wrong?
Set mytable = WordDoc.Tables.Add(myRange
mytable.Select
Selection.ParagraphFormat.
but I get an error message stating 'Object does not suppport this property or method'. Any ideas what I'm doing wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again, calacuccia, just what I wanted. Thanks to Datrius also for the initial help, cheers!
You're welcome, Robert.
Don't forget to delete your pointer questions:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=msoffice&qid=20165782
https://www.experts-exchange.com/jsp/qShow.jsp?ta=msoffice&qid=20165127
Don't forget to delete your pointer questions:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=msoffice&qid=20165782
https://www.experts-exchange.com/jsp/qShow.jsp?ta=msoffice&qid=20165127
Selection.ParagraphFormat.
for margins try :
With ActiveDocument.PageSetup
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(0.4)
.RightMargin = InchesToPoints(0.8)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
End with
hopes this helps