I looked at this example on another site, I donβt know if it will work in your case, since it requires Office PIA ...
var app = new Word.Application(); var doc = app.Documents.Open("path/to/file"); doc.Repaginate() var pageNumber = doc.BuiltInDocumentProperties("Number of Pages").Value as int;
source share