Printing & Formatting table issue

L

ljacomet

Hello,

I have an issue with programmatic printing of a word document.
The document is mainly data presented in a table. This table has a style
applied to it, that does the table formatting.

The problem is that this formatting happens 'some time' after opening the
document. The net result with programmatic printing is that the unformatted
table is printed.

I found no function to determine if some formatting was taking place or when
it is over. I tried going to the last page of the document, recovering the
page number, etc but had no success.

The current solution I have is a sleep of a few seconds to allow the
formatting to take place. This is not a long time solution as this time may
vary depending on the document size.

Here is some code showing my problem (VB .Net):
pageCount = oDoc.ComputeStatistics(Word.WdStatistic.wdStatisticPages)
System.Threading.Thread.Sleep(5000)
System.Console.WriteLine(pageCount & " pages before sleep, " &
oDoc.ComputeStatistics(Word.WdStatistic.wdStatisticPages) & " after")
oDoc.PrintOut(True)

This prints out the correct document, and outputs the line
9 pages before sleep, 5 after (as an example)
If I remove all code except the printout command, then the unformatted table
is printed.

Anyone has come across this problem and found a solution ?

Thanks you
Louis
 
H

Helmut Weber

Hi,
come across this problem yes
and found a solution
no, not really.

Except, maybe, making the value passed to sleep
dependant of the number of pages or some other
value representing (more or less) the complexity
of the formatting.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
L

ljacomet

Thank you for your answer.

I was hoping to have missed some API somewhere, it seems not.

Regards,
Louis
 

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