View Single Post
 
Old 06-18-2022, 02:17 AM
Winrow Winrow is offline Windows 10 Office 2016
Novice
 
Join Date: Jun 2022
Posts: 5
Winrow is on a distinguished road
Question List acronyms from selected tables after them with style

Hello everyone,

I've been trying to adapt to my needs the acronymlister macros I could find but I am stuck.

I have Word tables containing acronyms of 3 uppercase letters or more. I would like to run the macro on selected tables to find the acronyms within it and to list them right after each table. The list of acronyms should be formatted as
Quote:
ABC =
, use semi-colon as separator and, if at all possible, applied the Word style
Quote:
legend
.

Please find below the code I have been working on. I annotated where I think the code should be changed. Other options are welcome

Code:
Sub ACRO_table

Dim oTbl as Table
Dim oCel as Cell
Dim oRange as Range

For Each oTbl in Selection.Range.Tables
For Each oCel In oTbl.Range.Cells

With oCel.Range
With .find .text = "<[A-Z]{3,}>" .forward = True .Wrap = wdFindStop .Format = False .MatchCase = True .MatchWildCards = True
Do While .Execute ' the following lines of code are wrong i.e. it copies the found acronyms in new cells with new cells oTbl.Range.collapse wdCollapseEnd oTbl.Range.Copy oCel.Range.PasteAndFormat (wdTableOriginalFormatting) Loop End with End with Next oCel Next oTbl
Many thanks in advance.

Winrow

Last edited by Winrow; 06-18-2022 at 02:18 AM. Reason: typo in title
Reply With Quote