0

I've been working with many looooong RTF files filled with exam questions. I edit these in MS Word 2010. I've written a macro that will renumber those questions since the original numbering is far from sequential.

What is the best way to load that macro into each of the many RTF files so that I can run it for each?

I have saved the macro as a .bas file which can be loaded into Word for other documents, but it's a bit cumbersome to do that, so I'm wondering if there's a better way.

The macro will eventually be used by other people, so I'd rather not walk them through Word's VB macro editor screens if I can help it.

yukondude
  • 146

1 Answers1

1

Q: How should I load a macro when editing an RTF file?

  • Save this code in the normal.dot template
  • Replace the messagebox with your own code
    The code will only be executed if you open an existing .rtf file or create a new .rtf file

    Private Sub Document_Open()
        Call mycode
    End Sub
    
    Private Sub Document_New()
        Call mycode
    End Sub
    
    Sub mycode()
        If Not ActiveDocument.Name Like "*.rtf" Then Exit Sub             
        MsgBox "Insert your code here"            
    End Sub
    

Q: I want to share my Word macro with others automatically

  • Copy your normal.dot to a shared network so others can get it from there.
    The normal.dot is usually stored in %appdata%\Microsoft\Templates
    (differs for localized Office versions)

  • or you copy the file automatically using windows batch together with xcopy or robocopy.
    But this method needs access to drive C of every coworker

nixda
  • 27,634