+ Reply to Thread
Results 1 to 2 of 2

Help with word page breaks

Hybrid View

  1. #1
    Registered User
    Join Date
    06-11-2009
    Location
    manchester, england
    MS-Off Ver
    Excel 365
    Posts
    37

    Help with word page breaks

    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

  2. #2
    Registered User
    Join Date
    06-11-2009
    Location
    manchester, england
    MS-Off Ver
    Excel 365
    Posts
    37

    Re: Help with word page breaks

    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1