开发者

In Microsoft Word VBA, how do I check for repagination?

I am using Microsoft Word 2007. I open up some document with VBA and I need to do some work on them. However when a file is just opened, VBA do this repagination and doesn't wait for it to finish before continuing. So what would happen is that my code would then error because it think the opened document is only a few pages long when it's much longer.

My Code:

Documents.Open fileName:="C:\file.doc", Visible:=False
MsgBox ActiveDocum开发者_C百科ent.BuiltInDocumentProperties("Number of Pages")

I have tried to use sleep but it doesn't work, any ideas?


Try this:

Dim NewDoc As Document
Dim PageCount As Long

Set NewDoc = fileName:="C:\file.doc", Visible:=False
PageCount = NewDoc.ComputeStatistics(wdStatisticPages)

MsgBox PageCount
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜