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
When I paste in my table, each cell becomes a paragraph. This normal?Code: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
How is the next paragraph after the table identified?
Thanks for any help
I know this is something to do with the collapse method but I can't get it to work
If I manually create a blank doc in word and add a table I am trying the following but it doesn't work
activedocument.tables(1).range.Collapse wdCollapseEnd
activedocument.tables(1).range.InsertBreak
the break happens above the table, not below it
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks