Make these macros always available and portable

A

a.e.neuman

Hello experts,

I have two macros that I want to be available at all times (and easlily
portable to users). These macros instruct Word to show the document's FULL
PATH in Word's title bar - VERY useful indeed (I'll show the macros below).
The macros run automatically when a document is opened and/or saved.

Several times now Normal.dot has become corrupt and had to be replaced - and
we lost these macros and had to re-create them and they seem to go into
Normal.dot.

How can we make these macros available at all times (and secondly easily
portable to other users) and have them reside outside of Normal.dot?

Here are the macros;

------------------------------------------------
Sub AutoOpen()
'
' Macro added
'
ActiveWindow.Caption = ActiveDocument.FullName

End Sub

Sub FileSaveAs()
'
' Macro added
'

Dim pRange As Word.Range
Dim oFld As Field
On Error GoTo Handler
Retry:
With Dialogs(wdDialogFileSaveAs)
If .Show = 0 Then Exit Sub
End With
System.Cursor = wdCursorNormal
ActiveWindow.Caption = ActiveDocument.FullName
For Each pRange In ActiveDocument.StoryRanges
Do
For Each oFld In pRange.Fields
If oFld.Type = wdFieldFileName Then
oFld.Update
End If
Next oFld
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
ActiveDocument.Save
Exit Sub
Handler:
If Err.Number = 5155 Or Err.Number = 5153 Then
MsgBox Err.Decription, vbOKOnly
Resume Retry
End If

End Sub
 
P

Pranav Vaidya

Hi,

This is a common problem with Normal.dot.
You can save these macros in an Word add-in, do this...

Create a new word doc
Copy these macros
Save this file as .DOT
In the code, change the IsAddin property of the document to True

When you distiribute, just distirbute the template.
Add this template from 'Templates and Addins

You will also have to modify your code and include an auto_open routine
which overrides the application level event.
 
A

a.e.neuman

Thank you for the reply;

Can you please post how exactly to follow your recommendation -> "You will
also have to modify your code and include an auto_open routine which
overrides the application level event. "

Thankyou!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top