Help me find MS Word Visual Basic Code

I have a Microsoft Word document with Visual Basic code in it, and I can't find the code any longer. The document was saved as a "MS Word Macro-Enabled Document" and I modified the Trust Center so that all documents will be opened with macros enabled (not recommended). STILL I can't find the code. There are no macros listed, and opening up the visual basic editor shows no code.

I am using Word 2016 (version 1801 Build 9001.2138 Click-To-Run))

Any suggestions?

Thank you.
Lev SeltzerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MacroShadowCommented:
Can you upload the file?
Lev SeltzerAuthor Commented:
Here is one file that hasn't been modified in 1.5 years. THe code was here originally.
Sample.docm
MacroShadowCommented:
hmm, I recognize a lot of that code, it was published on prog, some of it I wrote myself, lol.

You don't see the code in the document you've attached?
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Lev SeltzerAuthor Commented:
The code is from a freelancer.com
I press alt-f11 and see the standard MS VB for Applications window, but the main window is blank, and clicking any object in the project displays nothing!
MacroShadowCommented:
Where is the document located?
Try putting it on your desktop.
MacroShadowCommented:
Sorry, I stand corrected.
The code I was referring to was not in your document.
Lev SeltzerAuthor Commented:
Oh. So when you look at the document you don't see anything, either?
So I have to find this code!
I have several other documents for this project, but they all seem to be lacking this code. I am not sure if it is because of a security setting, or because it is really missing!
MacroShadowCommented:
I see the code in the ThisDocument module.
Private Sub Document_New()
'1
Call ul
'2
Call ol
'3
Call se
Call es
Call st
Call em
Call qu
Call nb
Call br
Call p
Call tri
Call OtherSymbols
End Sub
Private Sub tri()
       With ActiveDocument.Content.Find
                .Text = Chr(13) & Chr(13) & Chr(13)
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
End Sub

Private Sub p()
       With ActiveDocument.Content.Find
                .Text = "<p>"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = Chr(13)
                .Execute Replace:=wdReplaceAll
End With
       With ActiveDocument.Content.Find
                .Text = "</p>"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = Chr(13)
                .Execute Replace:=wdReplaceAll
End With
End Sub
Private Sub br()
       With ActiveDocument.Content.Find
                .Text = "<br />"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
End Sub

Private Sub nb()
       With ActiveDocument.Content.Find
                .Text = "&nbsp;"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
End Sub

Private Sub qu()
       With ActiveDocument.Content.Find
                .Text = "&quot;"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = """"
                .Execute Replace:=wdReplaceAll
End With
End Sub
Private Sub OtherSymbols()
       With ActiveDocument.Content.Find
                .Text = "&nbsp;"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
End Sub
Private Sub st()
Set myRange = ActiveDocument.Range
documentText = myRange.Text
nextPosition1 = 1
i = 1
       emTerm = "<strong>"
       emTerm1 = "</strong>"
       startPos = InStr(nextPosition1, documentText, emTerm, vbTextCompare)
       
      If startPos > 0 Then
      Do Until nextPosition1 = 0
     
       startPos = InStr(nextPosition1, documentText, emTerm, vbTextCompare)
       stopPos = InStr(startPos, documentText, emTerm1, vbTextCompare)
       nextPosition1 = InStr(stopPos, documentText, emTerm, vbTextCompare)
       ActiveDocument.Range(startPos + 7, stopPos).Bold = True
      Loop
       End If
       With ActiveDocument.Content.Find
                .Text = "<strong>"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
       With ActiveDocument.Content.Find
                .Text = "</strong>"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
End Sub

Private Sub se()
Set myRange = ActiveDocument.Range
documentText = myRange.Text
nextPosition1 = 1
i = 1
       emTerm = "<strong><em>"
       emTerm1 = "</em></strong>"
       startPos = InStr(nextPosition1, documentText, emTerm, vbTextCompare)
       
      If startPos > 0 Then
      Do Until nextPosition1 = 0
     
       startPos = InStr(nextPosition1, documentText, emTerm, vbTextCompare)
       stopPos = InStr(startPos, documentText, emTerm1, vbTextCompare)
       nextPosition1 = InStr(stopPos, documentText, emTerm, vbTextCompare)
       ActiveDocument.Range(startPos + 11, stopPos).Bold = True
      ActiveDocument.Range(startPos + 11, stopPos).Italic = True
       Loop
       End If
       With ActiveDocument.Content.Find
                .Text = "<strong><em>"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
       With ActiveDocument.Content.Find
                .Text = "</em></strong>"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
End Sub
Private Sub es()
On Error Resume Next
Set myRange = ActiveDocument.Range
documentText = myRange.Text
nextPosition1 = 1
i = 1
       emTerm = "<em><strong>"
       emTerm1 = "</strong></em>"
       startPos = InStr(nextPosition1, documentText, emTerm, vbTextCompare)
       
      If startPos > 0 Then
      Do Until nextPosition1 = 0
       startPos = InStr(nextPosition1, documentText, emTerm, vbTextCompare)
       stopPos = InStr(startPos, documentText, emTerm1, vbTextCompare)
       nextPosition1 = InStr(stopPos, documentText, emTerm, vbTextCompare)
       If startPos > 0 And stopPos > 0 And stopPos - startPos < 250 Then
      ActiveDocument.Range(startPos + 11, stopPos).Bold = True
      ActiveDocument.Range(startPos + 11, stopPos).Italic = True
      Else
      End If
       Loop
       End If
       '
       With ActiveDocument.Content.Find
                .Text = "<em><strong>"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
       With ActiveDocument.Content.Find
                .Text = "</strong></em>"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
End Sub
Private Sub em()
Set myRange = ActiveDocument.Range
documentText = myRange.Text
nextPosition1 = 1
i = 1
       emTerm = "<em>"
       emTerm1 = "</em>"
       startPos = InStr(nextPosition1, documentText, emTerm, vbTextCompare)
       
      If startPos > 0 Then
      Do Until nextPosition1 = 0
       
       startPos = InStr(nextPosition1, documentText, emTerm, vbTextCompare)
       stopPos = InStr(startPos, documentText, emTerm1, vbTextCompare)
       nextPosition1 = InStr(stopPos, documentText, emTerm, vbTextCompare)
      ActiveDocument.Range(startPos + 2, stopPos).Italic = True
       Loop
       End If
       '
              With ActiveDocument.Content.Find
                .Text = "<em>"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
       With ActiveDocument.Content.Find
                .Text = "</em>"
                .Wrap = wdFindContinue
                .ClearFormatting
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
End Sub
Private Sub ol()
On Error Resume Next
firstTerm = "<li>"
secondTerm = "</ol>"
documentText = ActiveDocument.Range.Text
nextPosition = 1
Do Until nextPosition = 0

documentText = ActiveDocument.Range.Text
startPos = InStr(nextPosition, documentText, firstTerm, vbTextCompare) - 1
stopPos = InStr(nextPosition, documentText, secondTerm, vbTextCompare) + 3
ActiveDocument.Range(startPos, stopPos).Select
With Selection.Find
        Do While .Execute(FindText:="</li>", Forward:=False, Wrap:=wdFindStop) = True
              y = y + 1
              ActiveDocument.Range(startPos, startPos + 4).Select
              Selection.Text = y & ".   "
        Loop
       If y = y_old Then y = 0
        y_old = y
End With
nextPosition = InStr(nextPosition + 1, documentText, firstTerm, vbTextCompare)
Loop
Call ol_clear
End Sub
Private Sub ul()
On Error Resume Next
firstTerm = "<ul>"
secondTerm = "</ul>"
documentText = ActiveDocument.Range.Text
nextPosition = 1
Do Until nextPosition = 0
documentText = ActiveDocument.Range.Text
startPos = InStr(nextPosition, documentText, firstTerm, vbTextCompare) - 1
stopPos = InStr(nextPosition, documentText, secondTerm, vbTextCompare) + 3
ActiveDocument.Range(startPos, stopPos).Select
With Selection.Find
      .Text = "<li>"
               .ClearFormatting
                .Wrap = wdFindStop
                .Forward = True
                .Replacement.Text = Chr(149)
                .Execute Replace:=wdReplaceAll
End With
With Selection.Find
      .Text = "</li>"
               .ClearFormatting
                .Wrap = wdFindStop
                .Forward = True
                .Replacement.Text = "    "
                .Execute Replace:=wdReplaceAll
End With
nextPosition = InStr(nextPosition + 1, documentText, firstTerm, vbTextCompare)
Loop
Call ul_clear
End Sub
Private Sub ul_clear()
With ActiveDocument.Content.Find
                .Text = "<ul>"
               .ClearFormatting
                .Wrap = wdFindStop
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
With ActiveDocument.Content.Find
                .Text = "</ul>"
               .ClearFormatting
                .Wrap = wdFindStop
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
End Sub
Private Sub ol_clear()
With ActiveDocument.Content.Find
      .Text = "<ol>"
               .ClearFormatting
                .Wrap = wdFindStop
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
With ActiveDocument.Content.Find
      .Text = "</li>"
               .ClearFormatting
                .Wrap = wdFindStop
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
With ActiveDocument.Content.Find
      .Text = "</ol>"
               .ClearFormatting
                .Wrap = wdFindStop
                .Forward = True
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
End With
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lev SeltzerAuthor Commented:
That is the code I am looking for! Great. Now how do I get it?
Obviously I used to see it and it is in the document, and there is something not right here - some security setting that I need to get around!
Lev SeltzerAuthor Commented:
Is there some way to see this code on my end? Is there a third party that will extract it? Will viewing it using Word online show it?
MacroShadowCommented:
Lev SeltzerAuthor Commented:
Isn't the trust center in Office 365 supposed to let me add folders? does it not work? Why would I need to modify the registry manually?
MacroShadowCommented:
I'm not familiar with Office 365, but even when using the built in dialogs, the information is saved to the registry.
Lev SeltzerAuthor Commented:
Thank you. I still can't see the code here in that file, but at least I have an original copy. The highly edited version seems to be lost forever.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.