Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-04-2024, 10:05 AM
skydivetom skydivetom is offline Modify Existing REGEX Macro to Extract Acronyms Windows 11 Modify Existing REGEX Macro to Extract Acronyms Office 2019
Novice
Modify Existing REGEX Macro to Extract Acronyms
 
Join Date: Mar 2023
Posts: 9
skydivetom is on a distinguished road
Default Modify Existing REGEX Macro to Extract Acronyms

Hello,

I currently use a REGEX-based macro in MS Word to extract all uppercase words and generate a separate document listing these words in a table. This has been particularly helpful for creating acronym lists, such as those used in appendices. However, I would like to modify the existing macro to reduce "false positives"—specifically, words that are in uppercase but are not actual acronyms.

To illustrate, I have attached two sample documents along with their respective outputs:

1. "Sample Document with Acronyms v01"
Contents: This document contains 10 uppercase acronyms highlighted in green. There is also a mixed-case acronym ("IoT," standing for "Internet of Things") marked in yellow. The current macro does not recognize mixed-case acronyms.

Process:
  • Open the document.
  • Select "View" from the Office ribbon.
  • Navigate to "Macros" > "View Macros" and run "ExtractAcronymsToNewDocument."
  • The macro generates a new Word document listing all found uppercase words in a table, with columns for "Acronym," "Definition" (left blank), and "Page" (indicating the first occurrence).
  • Outcome: This method works well but misses the mixed-case acronym ("IoT").

2. "Sample Document with Acronyms v02"
Contents: This is a copy of v01 with added words ("TABLE OF CONTENTS," "PARA #1," "PARA #2") marked in red. These uppercase headers are not acronyms but are extracted by the macro.
Process: Running the macro results in a new document listing the 10 green acronyms, but also includes the 4 additional uppercase header words (false positives).
Issues with the Current Macro:
Over-Inclusion: The macro extracts all uppercase words, including headers and other non-acronym text.
Under-Inclusion: It does not extract acronyms that use mixed-case formatting, such as "IoT."

Questions:
Q1: How can the REGEX macro be adjusted to only include uppercase words within parentheses, potentially reducing false positives?
Q2: Is there a way to modify the macro to extract mixed-case acronyms like "IoT," in addition to the standard uppercase acronyms?

Even a solution that addresses only Q1 would be highly valuable, as the current macro generates an overwhelming number of false positives in lengthy documents.



Thank you for considering my request, and I appreciate any guidance you can provide!
Attached Files
File Type: zip Sample Documents and Outputs.zip (44.1 KB, 5 views)
Reply With Quote
  #2  
Old 11-04-2024, 03:22 PM
macropod's Avatar
macropod macropod is offline Modify Existing REGEX Macro to Extract Acronyms Windows 10 Modify Existing REGEX Macro to Extract Acronyms Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,341
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Since you haven't supplied your RegEx code, no-one is going to be able to help you with that. However, see: https://www.msofficeforums.com/word-...generator.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-04-2024, 03:31 PM
skydivetom skydivetom is offline Modify Existing REGEX Macro to Extract Acronyms Windows 11 Modify Existing REGEX Macro to Extract Acronyms Office 2019
Novice
Modify Existing REGEX Macro to Extract Acronyms
 
Join Date: Mar 2023
Posts: 9
skydivetom is on a distinguished road
Default

Paul -- the existing REGEX code is included in the MS-Word document.

Again, please follow the provided instructions:
Open the document.
Select "View" from the Office ribbon.
Navigate to "Macros" > "View Macros" and run "ExtractAcronymsToNewDocument."

Also, see attached PNG.
Attached Images
File Type: png Code.png (149.2 KB, 14 views)
Reply With Quote
  #4  
Old 11-04-2024, 04:16 PM
macropod's Avatar
macropod macropod is offline Modify Existing REGEX Macro to Extract Acronyms Windows 10 Modify Existing REGEX Macro to Extract Acronyms Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,341
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

All your zipped documents are in the docx format. Documents in the docx format cannot contain macros.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 11-04-2024, 06:12 PM
skydivetom skydivetom is offline Modify Existing REGEX Macro to Extract Acronyms Windows 11 Modify Existing REGEX Macro to Extract Acronyms Office 2019
Novice
Modify Existing REGEX Macro to Extract Acronyms
 
Join Date: Mar 2023
Posts: 9
skydivetom is on a distinguished road
Default

I downloaded the zip file from the forum and all code was there.
Reply With Quote
  #6  
Old 11-04-2024, 08:39 PM
macropod's Avatar
macropod macropod is offline Modify Existing REGEX Macro to Extract Acronyms Windows 10 Modify Existing REGEX Macro to Extract Acronyms Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,341
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

As I said:
Quote:
Originally Posted by macropod View Post
All your zipped documents are in the docx format. Documents in the docx format cannot contain macros.
Undoubtedly, your documents are attached to a template that contains the macro, which makes the macro available to the documents - but only on your system.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help where to modify the macro John Brito Word VBA 2 12-22-2022 12:29 AM
Modify Existing REGEX Macro to Extract Acronyms how modify a macro code tarikov2006 Excel Programming 1 11-18-2016 04:10 AM
Macro help regex subspace3 Word VBA 1 10-15-2014 09:53 AM
Modify Existing REGEX Macro to Extract Acronyms Macro to create list of acronyms lsmcal1984 Word 3 09-04-2013 07:33 AM
Outlook 2010 and modify font on existing e-mail snowens Outlook 1 04-06-2011 01:57 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:32 PM.


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