Here's an oddity... very annoying as it has screwed up some custom
commenting functionality and I can't find a fix or workaround...
[Applies to Word 2002, all updates except the OWC vulnerability patch
applied; Vista HP SP1 + updates; Intel Core Duo laptop, 2GB RAM]
Since probably some time in Feb 2008, Word 2002 seems to unpredictably
change the case of the username text when creating the Author (VBA)/
Reviewer Name (UI) for comments...
It's not uniformly UPPER case, lower case or Title case and, worst of all
which, username strings will be transformed and how is not stable.
Can anyone else reproduce it? Is there any fix?
I know Word 2002 is out of "mainstream support" but if this is a bug
introduced by some recently security patch I hope MS will undo the damage...
Further info...
It only seems to affect short usernames ~<=4 characters, although I had one
longer example ("CuZs" which became "cUzS" - but this did not re-occur after
a system restart - manually set that rather than rely on the random number
generator to reproduce it) It could be the probability of error just
decreases with string length (in a run in which string length was 4-10 -
each 100 times - no errors were enountered) but that's no gurantee...
Here's some banged together code that randomly changes the username, creates
comments, checks the Author string against the username and leaves only
those that don't match... [what's the pattern (if any)?]
Same results run to run, same results if word is shutdown and restarted;
*different* results after system restart!
Sub usernameTesting()
Dim aStr As String
Dim aChar As String
Dim i As Long
Dim j As Long
Dim k As Long
Dim aRange As Range
Dim oldUser As String
Dim aCom As Comment
Documents("username test.doc").Activate
oldUser = Application.UserName
Application.ScreenUpdating = False
i = Int(Rnd(-1)) ' force sequence to repeat so runs can be compared
For i = 1 To 100
For j = 1 To 8
aStr = ""
For k = 1 To j
aStr = aStr & randChar
Next
Selection.InsertAfter aStr & vbCr
Set aRange = ActiveDocument.Words(ActiveDocument.Words.Count -
2)
Application.UserName = aStr
Set aCom = ActiveDocument.Comments.Add(aRange, aStr)
If aCom.Author <> aStr Then
Debug.Print i, aStr, "->", aCom.Author
Else
aRange.MoveEnd unit:=wdCharacter, Count:=1
aRange.Delete
End If
Next
Next
Application.UserName = oldUser
Application.ScreenUpdating = True
End Sub
Function randChar() As String
Dim j As Long
randChar = Chr(Int((Asc("Z") - Asc("A") + 1) * Rnd + Asc("A")))
j = Int(Rnd * 10)
If j Mod 2 = 0 Then
randChar = LCase(randChar)
End If
End Function
Sub testRandCharReproducibility()
Dim i As Long
i = Int(Rnd(-1)) ' force sequence to repeat so runs can be compared
For i = 1 To 10
Debug.Print randChar
Next
End Sub
--
Julian I-Do-Stuff
Some Vista stuff, but mostly just Stuff at http://berossus,blogspot.com