Jean-Guy:
I did not author the macros (I'm clueless about Visual basic). The specfic
macro in this issue is the HK_changeProjectName. In case it's relevant, I am
pasting below all the code used in our macros.
Thanks for the digging on this weirdness. I have not encountered this before.
'NOTES:
'
'Make sure that everything under the References folder is a valid
document/template.
'If there are any other files referenced, copy all the macros to a text
file, delete the macros here, save the document, reopen and then paste the
macros back in.
'That should reset any corrupted references.
'Also check under Tools->Templates and Add-Ins to make sure the only the
Normal template is being loaded.
'
'Updates the given text field with a value from the user
Private Sub changeTextField(msg As String, propName As String)
Dim userInput As String
'get user input
userInput = InputBox(msg)
'change doc property
ActiveDocument.CustomDocumentProperties(propName).Value = userInput
End Sub
'Updates the given date field with a valid date from the user
Private Sub changeDateField(msg As String, propName As String)
Dim userInput As Variant
'get user input
Do
userInput = InputBox(msg)
Loop While Not (IsDate(userInput))
'change doc property
ActiveDocument.CustomDocumentProperties(propName).Value =
Format(userInput, "mmmm d, yyyy")
End Sub
'make sure all fields in the document have the most current value
Private Sub updateFields()
Dim aStory As Range
Dim nextStory As Range
'update the fields in each document area type (story)
For Each aStory In ActiveDocument.StoryRanges
'since StoryRanges only returns the first Story of each type...
'...we need to make sure we check all the Stories of this type
Set nextStory = aStory
Do
nextStory.Fields.Update
Set nextStory = nextStory.NextStoryRange
Loop While Not (nextStory Is Nothing)
Next aStory
End Sub
'Gets new project name
Public Sub HK_changeProjectName()
changeTextField "Please enter new project name:", "HK_ProjName"
updateFields
End Sub
'Gets new customer name and updates
Public Sub HK_changeCustomerName()
changeTextField "Please enter new customer name:", "HK_CustName"
updateFields
End Sub
'Gets new customer name and updates
Public Sub HK_changeProposalNumber()
changeTextField "Please enter new proposal number:", "HK_PropNumber"
updateFields
End Sub
'Gets new publish date and updates
Public Sub HK_changePublishDate()
changeDateField "Please enter new publish date. Use the following
format: mm/dd/yyyy", "HK_PubDate"
updateFields
End Sub
'Gets new rev number and updates
Public Sub HK_changeRevisionNumber()
changeTextField "Please enter new revision number. Use the following
format: x.x", "HK_Rev"
updateFields
End Sub
'Gets new values and updates Project Name, Customer Name, Proposal Number
and Publish Date custom fields
Public Sub HK_changeAllFields()
changeTextField "Please enter new project name:", "HK_ProjName"
changeTextField "Please enter new customer name:", "HK_CustName"
changeTextField "Please enter new proposal number:", "HK_PropNumber"
changeDateField "Please enter new publish date. Use the following
format: mm/dd/yyyy", "HK_PubDate"
updateFields
End Sub
'Updates the leading character on all the heading list styles (HK Header
Level #)
Public Sub HK_UpdateHeadingNumbering()
Dim headingLevels As ListLevels
Dim currentLevel As ListLevel
Dim toc As TableOfContents
Set headingLevels = ActiveDocument.Styles("HK Heading
1").ListTemplate.ListLevels
Dim newPrefix As String
Dim newStartAt As Integer
Dim existingFormat As String
Dim firstPercent As Long
newPrefix = InputBox("Please enter the new heading letter prefix:")
newStartAt = InputBox("Please enter the new heading starting number:")
For Each currentLevel In headingLevels
firstPercent = InStr(currentLevel.NumberFormat, "%") - 1
existingFormat = Right(currentLevel.NumberFormat,
(Len(currentLevel.NumberFormat) - firstPercent))
currentLevel.NumberFormat = newPrefix & existingFormat
If currentLevel.Index = 1 Then
currentLevel.StartAt = newStartAt
Else
currentLevel.StartAt = 1
End If
Next currentLevel
For Each toc In ActiveDocument.TablesOfContents
toc.Update
Next toc
End Sub