Do not allow row to break across pages when exporting to word

    In my previous blog i have given the solution for vertical table conversion in word.Similarly, this blog we are going to see another issue with word , table row to break across pages. In word, the table doesn’t fit in one page the remaining rows flows to next page, which is the general feature of word. This can be avoided in word settings manually. But when export automatically from Qlikview with a word template, this can’t be fixed. This can be achieved using vbscript in Qlikview Module while export. 

     

    Below script identify whether tables fits in same page or two pages, if tables splits in two pages then macro push the table to next page.


    Here are the steps,

     

    1. 1. Finding the page number where the table in word.

     

             CurPage1 = objSelection.Information (wdactiveendpagenumber)

     

    1. 2. Moving position of cursor after the table

      objSelection.Tables(1).Select
      objSelection.Collapse wdCollapseEnd

     

    1. 3. Finding the page number at after the table.

      CurPage2 = objSelection.Information (wdactiveendpagenumber)

     

    1. 4. Comparing page numbers, if same then continue with script otherwise move the tables down.

      If CurPage1<>CurPage2 then
      objSelection.Tables(1).Select
      objSelection.Collapse wdCollapseStart
      rLast =w  ‘ no.of.rows
      For r1 = 1 To rLast+1
      With objSelection.Tables(1).Rows(r1).Range.ParagraphFormat
      .KeepTogether = True  ‘keep the rows together
      .KeepWithNext = True ‘Moving to next page in word
      End With
      Next
      end if