Re: MoveRight in table fails at 1%: bug? workaround?



It might also help to clear the undo buffer from time to time in your code:
ActiveDocument.UndoClear

If you look for them, you'll probably notice that Word creates lots of large
temporary files as your macro runs, so that all changes can be undone.
Managing all those temporary files puts quite a burden on Word, and if you
remove that burden, this may allow your macro to run faster and without
running into problems.

That said, I've run quite often into problems where simple commands suddenly
stopped working in macros when working with tables. If I have some time, I'd
like to make some reproducable cases and make sure Microsoft gets the bug
reports. But these bugs seem really hard to pin down: Sometiimes a test case
I produced will run fine the next day, on the same document and the same
machine.

Regards,
Klaus



> Mic was telling us:
> Mic nous racontait que :
>
>> Hi, does anyone know sth. about erros at Selection.MoveRight command?
>>
>> I'm having a lot of trouble at an automatic function creating a Word
>> Document. VBA code runs for several hours (>5h) creating about 500
>> Documents, each 1 to 50 pages containing a table layout (7 columns)
>> and about 3 to 30 rows per page. Some table cells contain images
>> (rather small, about 2x3'').
>>
>> The error means Word is not doing a good job at creating a 2000 pages
>> pricelist every week. This is "Enterprise cristical" if documents
>> would not be re-viewed page by page.
>>
>> The code is started from a MS Access Database (using a
>> Word.Application with GetObject("Word.Application") and so on...).
>> All components are Office2003. Language: German (should not cause
>> trouble anyway).
>>
>> Error: Error.Number: 2147417851, Error.Description: Method _MoveRight_
>> failed for object _Selection_
>> Error occurs at VBA command:
>> Word.Application.Selection.MoveRight Unit:=wdCell
>>
>> Definately the selection mark is in the table at a cell when the
>> error occurs.
>>
>> It seems the Word.Application instance does not work properly after
>> having run some time. Errors do not occur at the same place at the
>> same document, but tend to strike long documents (>30 pages) more
>> likely, when simple text entries (by Selection.TypeText) need 10
>> times as long as they do in short documents.
>>
>> Hints and imagination about pagination have failed up to now, errors
>> do not only occur when moving right at the bottom of a page. The Word
>> process (TaskManager) looks ok, is not using more memory than normal.
>> Everything about the errors looks like being arbitrary.
>>
>>
>> Does anyone know something like a known bug about MoveRight? Is there
>> a workaround at least beeing able to minimize or limit errors? Could
>> I do anything not to get a 1% drop out rate?
>>
>> Thanks a lot.
>

"Jean-Guy Marcil" wrote:
> Without seeing the relevant code, it is hard to venture an answer.
>
> Meanwhile, the fact that you use "MoveRight" means that you are using the
> Selection object. Using the Selection object makes for more convoluted
> code that is less reliable and runs much slower, as you have observed.
>
> Since you are creating hundreds of documents, you should rewrite the code
> to use the Range object instead. It will run a lot faster and will be very
> stable.
>
>
> --
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@xxxxxxxxxxxxxxxxxxxxxxx
> Word MVP site: http://www.word.mvps.org
>


.



Relevant Pages

  • Re: closing a macro completely upon connect
    ... You mentioned 'temporarly' enters the command window. ... this is how all my macro definitions work, and are successful when used in ... :: Can you clarify your own posts? ... : aforementioned bug. ...
    (comp.protocols.kermit.misc)
  • Re: closing a macro completely upon connect
    ... fixed the bug associated with SET KEY and terminal mode, ... invoking a macro as a kverb works. ... interactively from the command prompt. ... A macro mapped to a key will not execute if you enter CONNECT mode ...
    (comp.protocols.kermit.misc)
  • Re: alt x oddity
    ... The bug and the fix is so vague. ... commands) and use that macro about a hundred times or so, ... Error #2 looking at the COMMAND window with a flashing cursor. ...
    (comp.protocols.kermit.misc)
  • Re: closing a macro completely upon connect
    ... I already created a work around to activate any macro via connect mode. ... also fail to execute the macro). ... All this time I was thinking the act of going to the command screen upon ... invokation was the bug itself. ...
    (comp.protocols.kermit.misc)
  • Wolfpack 4.3.10 Server Release
    ... Plug file descriptor leak in add command. ... This feature was flawed (it encourages players to ... Redesign of synchronization between commands, update and shutdown, ... The bug allowed players to delay ...
    (rec.games.empire)