I'm trying to create a new document based on a template which is stored on a network drive, to merge data to.
It will not load the first time, since there seems to be a Word 2010 bug, that Word is still initializing. It succeeds after several tries.
How can I create a loop that will try to create the document until it succeeds (try once every second for 5 seconds).
I thought I'd use something like this:
The red line is where i need help.
Is there a better way of doing this?
It will not load the first time, since there seems to be a Word 2010 bug, that Word is still initializing. It succeeds after several tries.
How can I create a loop that will try to create the document until it succeeds (try once every second for 5 seconds).
I thought I'd use something like this:
Code:
For i = 0 To 5
Set WordDoc = WordApp.Documents.Open("Z:\Templates\Test.dot")
i = i + 1
[COLOR=Red]if opening succeeded then exit for[/COLOR]
Next i
The red line is where i need help.
Is there a better way of doing this?