![]() |
|
|
|
#1
|
|||
|
|||
|
Hello. I am trying to run the macro found at the link below and having trouble.
https://www.msofficeforums.com/word-...generator.html I downloaded a copy of the relevant proposal document from SharePoint to my desktop. I'm on a company computer on a network using Office 365 and automatically synching (I think) everything to OneDrive. Since the proposal document for which I need an acronym list was crashing within seconds when I ran the macro, I made a one sentence document with this: This is a Project Management Plan (PMP), in which several Office of Program Manager (OPM) employees will conduct General Study Operations (GSO). The run brought up Compile error: Ambiguous name detected: ParseNumSeq As a guess (I am very much not a coder) I deleted code from End Sub on, reran the macro, and produced the expected table instantly. I then tried running it on a twelve-page partial copy of the proposal document (nearly 50 pages), only to have it crash again. I have not included the Manager macro, just the first one, sans the section indicated above. I can't provide the proprietary document. Here are some things I am guessing might be an issue; perhaps someone can advise. The document starts with a title page comprising a large table with text and a logo graphic over a background image. This is followed after a next page (NP) section break by a hyperlinked TOC and TOF. After another NP section break, the proposal content begins. The document includes additional NP section breaks. Otherwise, nothing extraordinary about the proposal document -- text, graphics, tables, captions, etc. Any help will be appreciated, as always. |
|
#2
|
||||
|
||||
|
That error message suggests your code module has two or more copies of the ParseNumSeq Function
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Although I find the Parse term in other macros in my VBA page, I find only one in the Acronym Lister. Here it is, as copied, and with the section I indicated in my OP deleted. (I am at sea with all this code, and am no sailor.)
Code:
Sub AcronymLister()
Application.ScreenUpdating = False
Dim StrTmp As String, StrAcronyms As String, i As Long, j As Long, k As Long, Rng As Range, Tbl As Table
StrAcronyms = "Acronym" & vbTab & "Term" & vbTab & "Page" & vbTab & "Cross-Reference Count" & vbTab & "Cross-Reference Pages" & vbCr
With ActiveDocument
With .Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
.Wrap = wdFindStop
.Text = "\([A-Z0-9][A-Z&0-9]{1" & Application.International(wdListSeparator) & "}\)"
.Replacement.Text = ""
.Execute
End With
Do While .Find.Found = True
StrTmp = Replace(Replace(.Text, "(", ""), ")", "")
If (InStr(1, StrAcronyms, .Text, vbBinaryCompare) = 0) And (Not IsNumeric(StrTmp)) Then
If .Words.First.Previous.Previous.Words(1).Characters.First = Right(StrTmp, 1) Then
For i = Len(StrTmp) To 1 Step -1
.MoveStartUntil Mid(StrTmp, i, 1), wdBackward
.Start = .Start - 1
If InStr(.Text, vbCr) > 0 Then
.MoveStartUntil vbCr, wdForward
.Start = .Start + 1
End If
If .Sentences.Count > 1 Then .Start = .Sentences.Last.Start
If .Characters.Last.Information(wdWithInTable) = False Then
If .Characters.First.Information(wdWithInTable) = True Then
.Start = .Cells(.Cells.Count).Range.End + 1
End If
ElseIf .Cells.Count > 1 Then
.Start = .Cells(.Cells.Count).Range.Start
End If
Next
End If
StrTmp = Replace(Replace(Replace(.Text, " (", "("), "(", "|"), ")", "")
StrAcronyms = StrAcronyms & Split(StrTmp, "|")(1) & vbTab & Split(StrTmp, "|")(0) & vbTab & .Information(wdActiveEndAdjustedPageNumber) & vbTab & vbTab & vbCr
End If
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
StrAcronyms = Replace(Replace(Replace(StrAcronyms, " (", "("), "(", vbTab), ")", "")
Set Rng = ActiveDocument.Range.Characters.Last
With Rng
If .Characters.First.Previous <> vbCr Then .InsertAfter vbCr
.InsertAfter Chr(12)
.Collapse wdCollapseEnd
.Style = "Normal"
.Text = StrAcronyms
Set Tbl = .ConvertToTable(Separator:=vbTab, NumRows:=.Paragraphs.Count, NumColumns:=5)
With Tbl
.Columns.AutoFit
.Rows(1).HeadingFormat = True
.Rows(1).Range.Style = "Strong"
.Rows.Alignment = wdAlignRowCenter
End With
.Collapse wdCollapseStart
End With
For i = 2 To Tbl.Rows.Count
StrTmp = "": j = 0: k = 0
With .Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.Forward = True
.Text = Split(Tbl.Cell(i, 1).Range.Text, vbCr)(0)
.MatchWildcards = True
.Execute
End With
Do While .Find.Found = True
If .InRange(Tbl.Range) Then Exit Do
j = j + 1
If j > 0 Then
If k <> .Duplicate.Information(wdActiveEndAdjustedPageNumber) Then
k = .Duplicate.Information(wdActiveEndAdjustedPageNumber)
StrTmp = StrTmp & k & " "
End If
End If
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Tbl.Cell(i, 4).Range.Text = j
StrTmp = Replace(Trim(StrTmp), " ", ",")
If StrTmp <> "" Then
'Add the current record to the output list (StrOut)
StrTmp = Replace(Replace(ParseNumSeq(StrTmp, "&"), ",", ", "), " ", " ")
End If
Tbl.Cell(i, 5).Range.Text = StrTmp
Next
End With
Set Rng = Nothing: Set Tbl = Nothing
Application.ScreenUpdating = True
End Sub
|
|
#4
|
||||
|
||||
|
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#5
|
|||
|
|||
|
I'm sorry, Paul. I guess that means that I need to create a separate module for this macro. I'll try that Monday when I get to work. Thank you.
|
|
#6
|
||||
|
||||
|
No, it doesn't mean that at all. All it means is that you need to ensure there is only one copy of the ParseNumSeq Function in the module. Any number of macros can call that function.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| acronym list |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unlicensed acronym finder for PP? | Ulodesk | PowerPoint | 1 | 08-13-2019 12:37 AM |
Acronym finder
|
maceslin | Word VBA | 6 | 06-14-2019 09:03 AM |
| Acronym lister and definition checker for Microsoft Word | gwez | Word VBA | 1 | 06-13-2015 04:00 AM |
Acronym Finder
|
Cray_Z | Word VBA | 14 | 09-22-2014 11:42 PM |
| Auto correct for Acronym | mam9 | Word | 3 | 11-19-2012 01:35 AM |