View Single Post
 
Old 04-01-2024, 11:11 AM
TessaMurillo TessaMurillo is offline Windows Vista Office 2010
Advanced Beginner
 
Join Date: Mar 2024
Posts: 32
TessaMurillo has a little shameless behaviour in the past
Default

Hi Susan!

Yes, there are several ways to automate the process of building a table with texts of a given heading in the current document. Here is some sample VBA code that may help you with this task:

```vba
Sub BuildHeaderTable()
Dim doc As Document
Dim tbl As Table
Dim para As Paragraph
Dim headerText As String
Dim pageNumber As Integer
Dim row As Integer

'Open the current document
Set doc = ActiveDocument

' Create a new table on the active sheet
Set tbl = doc.Tables.Add(doc.ActiveWindow.Selection.Range, 1, 2)



Hope this helps you!
Reply With Quote