ASP Code Needed for counting numbers of pages in MS-Word file and no. of words in the document.

Posted on 2005-05-12
Last Modified: 2010-04-17
Hi All,

  I m in urgent need of a asp code for counting the total no. of  pages in a word file, and the word count.

I am trying this code -

Dim objWord
Dim objDoc
Set objWord = Server.CreateObject ("Word.Application")
Set objDoc = objWord.Documents.Open (Server.MapPath(("c:\WordABC.doc")))
wc = objWord.Documents.wordcount

response.write objDoc.readall
Set oWDoc = Nothing
Set oWord = Nothing

But getting following error -
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed

  Please help.
Question by:Subrojit
    1 Comment
    LVL 6

    Accepted Solution

    Do you have Word installed on the web server..?  It sounds like your application can't find the Object Library.  Also, Microsoft recommend you use "CreateObject" instead of "Server.CreateObject" when automating Office objects from an ASP page.


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    A short article about problems I had with the new location API and permissions in Marshmallow
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now