Word(97) VBA error 5668

V

VBALover

Hi All,

I wrote a macro in word(97 OSR2) to insert a row in a table and reset the
cells
format to what I want. This macro works fine with hotkey.

But if I execute the macro with many time (lets say crazyly hit the hotkey
many many times in a second), the error come out.

"execution stage error '5668':
"The format in this document settingis too complicated. Please save it
immediately"
(Originally is in Chinese)



I can end this error and then run the macro again without any error. However
if I run it crazyly again, same erros occurs.

If I run it slowly (one by one), error never happen.

What is happening?? What can I do to skip this error?


Thanks for advice!
 
J

Jonathan West

Hi VBALover,

Tables are complex beasts, and all that is happening is that you aren't
giving Word dime to catch up with what you are asking. Include a few
DoEvents commands in the macro just to give Word more of a chance to keep up
 
V

VBALover

Thanks for your advice first. However I am not so smart to udnerstand what
you said. Can you give me more examples (or a example) of what you say, pls
~~

Million Thanks ~
 
J

Jonathan West

VBALover said:
Thanks for your advice first. However I am not so smart to udnerstand what
you said. Can you give me more examples (or a example) of what you say,
pls

Just include the following 3 lines at the end of your macro

DoEvents
DoEvents
DoEvents
 
J

Jonathan West

VBALover said:
Thanks for your advice first. However I am not so smart to udnerstand what
you said. Can you give me more examples (or a example) of what you say,
pls

Just include the following 3 lines at the end of your macro

DoEvents
DoEvents
DoEvents

The idea behind this is to tell Windows to catch up with what has been going
on in Word.
 
V

VBALover

Oh.... let me try it first. Thanks ~~~

^_^


Jonathan West said:
Just include the following 3 lines at the end of your macro

DoEvents
DoEvents
DoEvents

The idea behind this is to tell Windows to catch up with what has been going
on in Word.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
 
V

VBALover

oh... I fail..

the error still com out.. Any more suggestion?

here is my code:
' reset format for 4th Col
With Selection.Cells
DoEvents
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
DoEvents
.LineWidth = wdLineWidth150pt '<--- Error always come out from
this line
End With
DoEvents
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
End With
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone

End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt

End With

Selection.Font.Bold = False
 

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