document succesfully loaded

H

Helmut Weber

Hi adi,
how can i know when a document finished loading after openning?
(using c#)

why do you want to know that?

Has it to do with code in an auto-macro?

A workaraound like the following might help,
for small documents.

Sub AutoExec()
'or autoopen or autonew or semething of that kind
Application.OnTime _
When:=Now + TimeValue("00:00:02"), _
Name:="continue"
End Sub

sub continue
' whatever
end sub

Or maybe something like this, which works even for
a 1000 pages document:

Option Explicit
Dim p1 As Long
Dim p2 As Long
Sub autoopen()
Selection.EndKey unit:=wdStory
p1 = Selection.Information(wdActiveEndPageNumber)
continue
End Sub

Sub continue()
p2 = Selection.Information(wdActiveEndPageNumber)
If p1 = p2 Then
MsgBox "ready"
Else
autoopen
End If
End Sub

Just to show a possible way, a workaraound.

With c#, you should be able to check wether
the process "WINWORD.EXE" is idle.
 
H

Helmut Weber

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

adi

hi,
what i'm trying to do is run a tester that check files in different sizes in
order to get the loading time of documents with different sizes...
i created many files and i'm trying to run the tester on those files, open
each of them and get its time...
 
H

Helmut Weber

Hi Adi,

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

Option Explicit
Dim p1 As Long
Dim p2 As Long
Dim t As Long
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


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