Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Count pages of word document
Author:
krishna
E-mail:
Click to e-mail author
Submitted:
8/16/2006
Version:
VB6
Compatibility:
VB6
Category:
Miscellaneous
Views:
18999
Counting the exact number of pages in any Word document.
Declarations:
public pages as integer '---------------------------------- 'After calling the function the pages global variable 'contains 'the number of pages '----------------------------------
Code:
Public Function DOCPRINT(ByVal filepath As String) On Error GoTo errs ''''----1 ST procedure Fails partialy ''' k = 0 ''' lretval = ShellExecute(0, "Print", filepath, "", "", 0) '----2nd procedure Dim WordObj As Word.Application Dim Doc As Word.document Set WordObj = New Word.Application Set Doc = WordObj.Documents.Open(filepath) pages = Doc.ComputeStatistics(wdStatisticPages) WordObj.Visible = False WordObj.DisplayAlerts = wdAlertsNone ' pages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) WordObj.PrintOut Background:=False '--- For waiting till Printer jobs get completes '----------------- Doc.Saved = True Doc.Close (True) WordObj.Quit Set WordObj = Nothing Exit Function Wait (5) errs: On Error Resume Next WordObj.Documents.Open filepath WordObj.PrintOut Background:=False, Copies:=1 ' pages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) WordObj.Quit Set WordObj = Nothing End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement