Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 10th, 2005, 01:37 AM
Authorized User
 
Join Date: Nov 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to bjackman Send a message via MSN to bjackman
Default charachter counting

Is there a way to have an access database get an accurate character count from a microsoft word document and can this be set up on some sort of loop or somethign to process every doc file in a folder and then store those values?
 
Old March 10th, 2005, 01:44 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Just curious - why would you want to count the characters in a document? There is probably a way to do it, but before you do, sometimes the reason you want to do it, another, easier way can be determined.

dartcoach
 
Old March 10th, 2005, 02:05 AM
Authorized User
 
Join Date: Nov 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to bjackman Send a message via MSN to bjackman
Default

because this project is for a transcription company, they get paid by the number of lines of text, you take the character count and divide that by 65, (average characters per line of text) to get a line count for the document, they then charge the doctor for the total number of lines in his dictation.

 
Old March 10th, 2005, 02:14 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

There's a way to read each line of a text document and store each line as a record on a table. You would then have to analyze each record within the table to eliminate the spaces, etc. Once that has been done, you could count the characters until you hit a space. Once you've been through the whole table, total up the characters and store the totals in table that has the document name and character total.

This process would have to be repeated for each .doc file in your folder. Let me check on a couple of things and I'll re-post tomorrow, if that's Ok.


dartcoach
 
Old March 10th, 2005, 02:23 AM
Authorized User
 
Join Date: Nov 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to bjackman Send a message via MSN to bjackman
Default

sounds like a plan, thnx for your help

 
Old March 10th, 2005, 03:22 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

So far, I can get most of what you want. The problem is, it doesn't work with .doc files. It works great on text files. I'll keep looking.


dartcoach
 
Old March 10th, 2005, 04:27 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kevin, Brandon,

Dont know if this will help but you can use Automation to inspect the documents Readability statictics to get the character count. You could recursivley call the following function to get character counts for all docs in a folder. There is also an enumeration in the properties of the document that gives you more statistics such as characters, characters with spaces, words, paragraphs etc. if you needed more detailed info.

Function GetWrdChars(strDoc As String) As Long
'Reference the Word 9.0 Object library
Dim objWord As Word.Application
Dim wrdDoc As Word.Document

    Set objWord = New Word.Application
    Set wrdDoc = objWord.Documents.Open(strDoc)

    GetWrdChars = wrdDoc.ReadabilityStatistics.Item("Characters").Va lue

    wrdDoc.Close
    objWord.Quit

End Function

Any good?

Jon
 
Old March 10th, 2005, 08:04 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Guys,

On further inspection you can actually get the line count aswell!

Function GetWrdLines(strDoc As String) As Long
'Reference the Word 9.0 Object library
Dim objWord As Word.Application
Dim wrdDoc As Word.Document

    Set objWord = New Word.Application
    Set wrdDoc = objWord.Documents.Open(strDoc)

    GetWrdChars = wrdDoc.BuiltInDocumentProperties("Number of Lines")

    wrdDoc.Close
    objWord.Quit

End Function

Jon
 
Old March 10th, 2005, 12:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Excellent, John! Just note: Whereas the number of characters in the document is constant from computer to computer, the number of lines is not. That's because fonts vary in size depending on what each user has installed on his or her computer.

If User B doesn't have quite the same font that User A has, Windows will try to approximate the font to the nearest cousin Computer B does have installed. If a proportional font is chosen then the number of lines will change based on "how fat or skinny" the letters are on the new font.

So if BJackman gives the company a detailed cost analysis and quotes 3,241 lines and the company finds 2,943 then they may complain. In theory, your second post could work, but BJackman could play it safe by counting characters (not lines) and using the 65-characters-per-line estimate. In that way, BJackman and the company will be comparing oranges to oranges, so to speak.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old March 10th, 2005, 01:14 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Brandon,
These guys are good! They are a whole lot smarter than me! I would definitely run with their suggestions.

Kevin
P.S. I was having fun writing custom code, but their way is much easier.

dartcoach





Similar Threads
Thread Thread Starter Forum Replies Last Post
replace equal charachter(=) in tag vsempoux XSLT 2 July 11th, 2008 03:38 AM
Error in Counting Jonas Access VBA 2 August 15th, 2006 12:21 AM
counting in XSL gezi XSLT 8 March 29th, 2006 06:50 PM
Chapter 10: Case Delete charachter sagh BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 August 1st, 2005 04:55 PM
Counting ?!? hcweb Classic ASP Basics 2 December 8th, 2003 05:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.