Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 10th, 2005, 01:37 AM
Authorized User
 
Join Date: Nov 2003
Location: Hillsboro, Ohio, USA.
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?
Reply With Quote
  #2 (permalink)  
Old March 10th, 2005, 01:44 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
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
Reply With Quote
  #3 (permalink)  
Old March 10th, 2005, 02:05 AM
Authorized User
 
Join Date: Nov 2003
Location: Hillsboro, Ohio, USA.
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.

Reply With Quote
  #4 (permalink)  
Old March 10th, 2005, 02:14 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
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
Reply With Quote
  #5 (permalink)  
Old March 10th, 2005, 02:23 AM
Authorized User
 
Join Date: Nov 2003
Location: Hillsboro, Ohio, USA.
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

Reply With Quote
  #6 (permalink)  
Old March 10th, 2005, 03:22 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
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
Reply With Quote
  #7 (permalink)  
Old March 10th, 2005, 04:27 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: , , United Kingdom.
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
Reply With Quote
  #8 (permalink)  
Old March 10th, 2005, 08:04 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: , , United Kingdom.
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
Reply With Quote
  #9 (permalink)  
Old March 10th, 2005, 12:42 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
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
Reply With Quote
  #10 (permalink)  
Old March 10th, 2005, 01:14 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:00 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.