How to test whether a document is fully loaded

S

Sunouchi

Hello everybody,
I am working with Office 2000 and VB(A)

I have to load huge documents.
It takes a long time before some documents are fully loaded. My code
has to check how many pages the document has.

the code I use is:
TotalPages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
MsgBox TotalPages

The problem is that the code doesn't know when the document is fully
loaded, so TotalPages comes up with the wrong information, only few
pages, even if the document has hundreds of pages.

Does anybody knows the solution?
Thanks in advance
Hans
 
J

Jonathan West

Hi Hans,

The document is loading OK, it is just taking its time paginating those
pages beyond the one visible on screen. Add the following line of code to
force a full repagination before you get the page count

ActiveDocument.Repaginate

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
H

Helmut Weber

Hi Sunouchi,

how about this guess (!), that after repagination
has been finished a document has been fully loaded?


Option Explicit
Dim p1 As Long ' number of pages at point 1 in time
Dim p2 As Long ' number of pages at point 2 in time
Dim t As Long ' time
Public Declare Function GetTickCount Lib "kernel32" () As Long

Sub autoopen()
t = GetTickCount
Selection.EndKey unit:=wdStory
p1 = Selection.Information(wdActiveEndPageNumber)
continue
End Sub


Sub continue()
Selection.EndKey unit:=wdStory
p2 = Selection.Information(wdActiveEndPageNumber)
If p1 = p2 Then
MsgBox GetTickCount - t
Else
autoopen
End If
End Sub

You might have to adjust it to your needs.

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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