An existing VB6 app uses Word automation to create/print reports. The posted code is a small snippet of the whole process but the majority of the code uses the these same Word methods/properties.
The first 3 lines of the attached picture are what normally gets created/printed. The bottom 3 lines are what is happening to 1 user but not all the time. The TypeText method is printing all the text in the same position. Sometimes closing/opening the app solves the problem but in some cases a re-boot is necessary.
I don't know much about Word and need some suggestions on how to begin to troubleshoot this problem.
i would avoid working with the selection object, better to work with a specific range, but i doubt that has any bearing on your problem
what is the next few lines of your code?
if you check the document before this section of code is some part of the incorrect text already there?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
What happens if you put this line just before this block:
Code:
wdApp.ActiveDocument.Activate
Pradeep, Microsoft MVP (Visual Basic) Please appreciate posts that have helped you by clicking icon on the left of the post.
"A problem well stated is a problem half solved." — Charles F. Kettering
Pradeep, the code does use .Activate its just not shown in the snippet.
westconn, I cannot recreate the problem and was hoping I wouldn't have to create a special "trouble shooting" version of the app to solve this problem. The user is at a remote site and well, not very cooperative (and a little cranky).
The rest of the code is basically the same. It goes on to write the contents of a recordset to the document using the TypeText method, setting and clearing TabStops etc.
what i was trying to determine was at what point the additional text was being inserted
is he using any different language packs etc, as the characters look chinese
what else he may be doing while the code is running
if the code is writing to a new document, what template is it based on
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
There is no "additional text". The top of the sample graphic I posted is the normal output. The bottom is the corrupted output. I created the graphic by copying 3 lines of text from two different documents.
There is no "additional text". The top of the sample graphic I posted is the normal output. The bottom is the corrupted output. I created the graphic by copying 3 lines of text from two different documents.
is printing each character at the exact same location/position.
What code lines print those "2008-1865" text? I think problem might be near that.
Pradeep, Microsoft MVP (Visual Basic) Please appreciate posts that have helped you by clicking icon on the left of the post.
"A problem well stated is a problem half solved." — Charles F. Kettering
sorry, i thought it was all in the same document, rather than image of 2 docs
looks like it is just some corruption of the strings passed to the document, although the formatted numbers still print correctly
maybe comes back to what language packs
actually it almost looks like all the characters are printed one on top of the other
can you get /post a sample document, with the anomaly?
Last edited by westconn1; May 4th, 2009 at 06:42 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
As the problem happened on only 1 user's PC and not all the times, I think that PC has some problem with Ms-Word when it try to render that font (is that Arial?) at some particular sizes or Zoom.
Request a reinstall of Ms-Word to see what happens.
Sometimes I saw a similar sympton on webbrowser on my PC when I changed text size.
I don't think the problem is in your code although it is not "professional" as it uses Selection to move the pointer (as pete mentioned).
Don't forget to use [CODE]your code here[/CODE] when posting code
If your question was answered please use Thread Tools to mark your thread [RESOLVED]
I realize this is an old thread, but I have encountered a nearly identical problem and I’m wondering how it was solved. We also have some printouts with several paragraphs, but all the characters in each paragraph are scruched to the same spot to look like blobs of characters in the line 1 column 1 of the immedate text.
We’re using Win2k3 and Office 2003. We use automation to generate the final documents in a medical transcription reporting application. Most of the document printouts are perfect, but in some installations (not all systems) we getting ~2/1000 printouts like this.
Did you determine the cause? And, how did you solve it?