Microsoft Office Word 2011 version 14.5.5
I reviewed and tried both of these threads which refer to version 14.4.9 and an earlier version
http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macword/my-macro-to-run-when-a-new-file-is-created-only/3940ad72-eec5-41d2-b7b9-94b68c36aec2
- adding a one second delay in Auto_New
Sub AutoNew()
Dim PauseTime, Start
' Add a pause to allow time for Word to open before continuing
PauseTime = 1 ' Set duration in seconds
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
End Sub
http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macword/mac-word-documentnew/cf113d91-7709-44ce-96f7-2871eefbd119
- adding HavePatience in Auto_New and Auto_Open which checks Application.Documents.Count < 1
Sub AutoNew()
HavePatience
End Sub
Sub AutoOpen()
HavePatience
End Sub
Sub HavePatience()
If StopCount > 9 Then
MsgBox "Sorry, your document failed to open."
StopCount = 0
End sub
End If
StopCount = StopCount + 1
weThereYet = Application.Documents.Count
If weThereYet < 1 Then
Application.OnTime Now + TimeValue("00:00:01"), "HavePatience"
end if
End Sub
Neither solution causes Document_New or Document_Open to be called consistently. In about 30 tries, I saw my MsgBox debug code once. I have resorted to checking one of my arrays to determine if the initialization code was run before running commands on my
toolbar. I have also tried calling Sleep 1000 with no luck. Is one second too short or has someone found another workaround? Being able to distinguish between new and open would be useful.