I am pretty new to vba but am getting the hang of access and excel quite well.
I am running an excel macro and trying to export ranged of cells to word. i can manage to format my title and paste in the fist table but after that i want to insert a page break and change to landscape.
I am struggling to select anything after the table.
here is my code (part of a much larger sheet)
dtable is a predefined range of cells from another macro
Sub export()
Dim WordApp As Word.Application
'select details table
Sheets("detail").Activate
Range(dtable).Copy
'open word and template doc
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Open "c:\template"
WordApp.Visible = True
'insert details table
With WordApp.ActiveDocument
.Paragraphs(1).Range.Text = "Quality Metrics"
.Paragraphs(1).Range.InsertParagraphAfter
.Paragraphs(2).Range.InsertParagraphAfter
.Paragraphs(3).Range.Text = "Details"
.Paragraphs(3).Range.InsertParagraphAfter
.Paragraphs(4).Range.InsertParagraphAfter
.Paragraphs(5).Range.PasteAndFormat (wdPasteDefault)
End With
With WordApp.ActiveDocument.Paragraphs(1)
.Range.Font.Name = "arial"
.Range.Font.Size = 12
.Range.Font.Bold = True
.Range.Font.Underline = wdUnderlineSingle
.Alignment = wdAlignParagraphCenter
End With
With WordApp.ActiveDocument.Paragraphs(3)
.Range.Font.Name = "arial"
.Range.Font.Size = 10
.Range.Font.Underline = wdUnderlineSingle
End With
WordApp.ActiveDocument.Tables(1).Rows(1).Cells.VerticalAlignment = wdCellAlignVerticalCenter
When I paste in my table, each cell becomes a paragraph. This normal?
How is the next paragraph after the table identified?
Thanks for any help
Bookmarks