Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2024, 11:11 AM
TessaMurillo TessaMurillo is offline Looking for macro Windows Vista Looking for macro 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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perfect macro not working when its code is inserted in larger macro RobiNew Word VBA 3 10-18-2023 03:19 AM
Macro to Remove Paras with Line Spac 6; Macro to Convert Paragraphs to Outline Numbered venganewt Word VBA 0 01-25-2022 06:28 PM
Looking for macro Footnote extraction macro [Why is this macro so slow? / anyway to make it faster?] Le_Blanc Word VBA 10 03-22-2021 11:38 AM
Spell check macro within macro button field doesn't work in one document samuelle Word VBA 0 07-20-2016 02:27 AM
Looking for macro Macro Question: Need help making a macro to highlight the first word in every sentence LadyAna Word 1 12-06-2014 10:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:24 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft