none
Use dynamic table content as text Heading on succeeding pages RRS feed

  • Question

  • Hi,

      I would like to know if it's possible in Microsoft Word to use dynamic table contents as Heading on succeeding pages.  For example, I have an empty table of To Do list on page 1. If I add a new row, it will automatically be inserted on page 2 as a new heading 1(simple new text with Heading 1 format).  If I decide to add another row, its content will be inserted as a new heading 1 on page 3, and so on and so forth.  If there no page 3, it will automatically create page 3.

    Example:

    Table Page 1:

    row1: "Discover MS dev tools"

    row2: "Share knowledge"

    On Page 2, "Discover MS Dev Tools" is automatically inserted as Heading 1.  On Page 3, "Share Knowledge" is automatically inserted as Heading 1.  If there is no page 3, create page 3 and insert the text defined in row 2.

    It's like table of contents functionality, but the other way around.

    Just as background, I'm new to any forms of MS Office development.  I recently discovered the concept of fields and became curious on the other features of MS Office.  I'm not sure if this is can be done using Basic MS Word alone or if I need to use another tool/application.  Any information will be highly appreciated.

    Thank you!





    • Edited by petjosB Friday, April 10, 2015 9:33 AM
    Thursday, April 9, 2015 6:21 PM

Answers

  • Hi petjosB,

    You may have a table in page 1 and based on the table’s content to add heading to each page, also automatic add heading when add new row with content.

    For this scenario, you could capture the WindowSelectionChange event and compare the table’s row count, if it adds a new row, then add new heading in a new page.

    Simple code to register event:

    Public WithEvents appWord As Word.Application
     
    Private Sub appWord_WindowSelectionChange _
     (ByVal Sel As Selection)
     Dim t As Table
     If Sel.Tables.Count = 1 Then
        Set t = Sel.Tables(1)
        Debug.Print t.Rows.Count
     End If
    End Sub

    For the hyperlink/reference, you could add the cross-reference, then if the heading changes, you could update the field.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, April 14, 2015 2:42 AM
    Moderator

All replies

  • Hi petjosB,

    Do you want ot add the header of page or the header of table?

    Add header of page:

    If there are just two different headers, that is easy to accomplish. There is PageSetUp.OddAndEvenPagesHeaderFooter property that used to set the different headers and footers for odd-numbered and even-numbered pages in the document.

    Then, you just need to get the content in a table’s row and specify to the header to achieve your requirement.

    If there are more than two different headers, I think you need to set PageSetup.DifferentFirstPageHeaderFooter property to true and specify each header for the document (Iterate sections of document).

    To add a new page, we could use InsertBreak method.

    Application.Selection.EndKey Unit:=wdStory
    Application.Selection.InsertBreak

    Add header of table:

    For this senario, I think you need to specify the text and change the format for the correspoding row.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Friday, April 10, 2015 7:39 AM
    Moderator
  • Hi petjosB,

    You may have a table in page 1 and based on the table’s content to add heading to each page, also automatic add heading when add new row with content.

    For this scenario, you could capture the WindowSelectionChange event and compare the table’s row count, if it adds a new row, then add new heading in a new page.

    Simple code to register event:

    Public WithEvents appWord As Word.Application
     
    Private Sub appWord_WindowSelectionChange _
     (ByVal Sel As Selection)
     Dim t As Table
     If Sel.Tables.Count = 1 Then
        Set t = Sel.Tables(1)
        Debug.Print t.Rows.Count
     End If
    End Sub

    For the hyperlink/reference, you could add the cross-reference, then if the heading changes, you could update the field.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, April 14, 2015 2:42 AM
    Moderator