Word XP, command failed (4198) after 230 pages

L

Linus M

H

My problem is when I am printing to a word XP document using selection.
The error ususaly comes between 220 - 270 pages and it is never the same place in the code that generates the error
when I use Word 2K this problem rearly occures but in Word XP it always occure.
The program saves after each page and every page looks almost the same apart from the text and diffrent tables, due to diffrent text, that is retreived from an Access database.

If anyone have any idea of this problem all help would be appricated
Thank
/Linu

OS WinX
WORD X
VB 6.
Here is part of the code that has been executed on every page before this error on page, 230

Selection.Shading.BackgroundPatternColor = wdColorGray2
Selection.Font.Bold = Tru
Selection.TypeText Text:="Function definition
Selection.MoveRight Unit:=wdCharacter, Count:=
Selection.TypeText Text:="Name
Selection.MoveRight Unit:=wdCel
Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExten
Fail -> Selection.Cells.Merg
Selection.TypeText Text:=V_FktNam
Selection.MoveRight Unit:=wdCharacter, Count:=

Selection.TypeText Text:="FBID
Selection.MoveRight Unit:=wdCel
Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExten
Selection.Cells.Merg
Selection.TypeText Text:=V_FbI
Selection.MoveRight Unit:=wdCharacter, Count:=

Selection.TypeText Text:="FktID
Selection.MoveRight Unit:=wdCell
 
D

Doug Robbins - Word MVP

Without seeing all of your code, it's hard to give you any advice other than
you should try and avoid using the Selection object. I would think that if
you rewrote the code to do that, you would probably eliminate the problem.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
Linus M said:
Hi

My problem is when I am printing to a word XP document using selection.
The error ususaly comes between 220 - 270 pages and it is never the same
place in the code that generates the error.
when I use Word 2K this problem rearly occures but in Word XP it always occure.
The program saves after each page and every page looks almost the same
apart from the text and diffrent tables, due to diffrent text, that is
retreived from an Access database.
 
L

Linus M

H

unfortunatly I can't rewrite all the code. I don't have the time since the code is massive with several thousand lines of code

Thanks any way
/linu
----- Doug Robbins - Word MVP wrote: ----

Without seeing all of your code, it's hard to give you any advice other tha
you should try and avoid using the Selection object. I would think that i
you rewrote the code to do that, you would probably eliminate the problem

-
Please post any further questions or followup to the newsgroups for th
benefit of others who may be interested. Unsolicited questions forwarde
directly to me will only be answered on a paid consulting basis

Hope this help
Doug Robbins - Word MV
Linus M said:
H
The error ususaly comes between 220 - 270 pages and it is never the sam
place in the code that generates the error
when I use Word 2K this problem rearly occures but in Word XP it alway occure
The program saves after each page and every page looks almost the sam
apart from the text and diffrent tables, due to diffrent text, that i
retreived from an Access database
 
D

Doug Robbins - Word MVP

Which could probably have been done with a few lines and a Loop.

Re-writing the code may be the only way around your problem.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
Linus M said:
Hi

unfortunatly I can't rewrite all the code. I don't have the time since the
code is massive with several thousand lines of code.
 
L

Linus M

I fear that it is the case but the company will not pay for that, sadly
I do agree that the code is not the best I was assigned to bugg fix the code :

Some final questions
Is there a limitation in the selection object
how big can a selection be
Is the range object to prefer or is there a better way of writing a document

Thanks for you input
/linu


----- Doug Robbins - Word MVP wrote: ----

Which could probably have been done with a few lines and a Loop

Re-writing the code may be the only way around your problem

-
Please post any further questions or followup to the newsgroups for th
benefit of others who may be interested. Unsolicited questions forwarde
directly to me will only be answered on a paid consulting basis

Hope this help
Doug Robbins - Word MV
 
K

Klaus Linke

Hi Linus,

I think the most likely cause for the error is that you are no longer in any
table after "Selection.MoveRight".

Perhaps you can just insert some code to test for that condition ("If
Selection.Information(wdWithInTable) = False then ' skip the rest and go to
the next table).

Greetings,
Klaus
 

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