?
Solved

Character count in Word doc

Posted on 2003-03-05
4
Medium Priority
?
247 Views
Last Modified: 2010-04-07
I've the following lines in my code :

Dim Appl_Dcmt_Word As Word.Application
Dim VarO_Dcmt_Rang_Word As Range

Set VarO_Dcmt_Rang_Word = Appl_Dcmt_Word.Selection.Range

VarO_Dcmt_Rang_Word.SetRange Start:=VarO_Dcmt_Rang_Word.Start, End:=Appl_Dcmt_Word.ActiveDocument.Characters.Count
VarO_Dcmt_Rang_Word.Select


The problem is that the number of characters is too small of Appl_Dcmt_Word.ActiveDocument.Characters.Count.  There are a few characters (+-10) that aren't selected.
 
Has somebody the same problem ???
0
Comment
Question by:zombieman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Expert Comment

by:Steiner
ID: 8071940
Not if that's what you want, but try this instead (at least it worked with my document where your code did not select all characters up to the end):

Sub test2()
Dim Appl_Dcmt_Word As Word.Application
Dim VarO_Dcmt_Rang_Word As Range

Set Appl_Dcmt_Word = Application
Set VarO_Dcmt_Rang_Word = Appl_Dcmt_Word.Selection.Range

ActiveDocument.Range(Selection.Start, ActiveDocument.Range.End).Select
End Sub

Maybe there are some characters that are not counted correctly (formatting chars??)

Greets
Steiner
0
 
LVL 9

Accepted Solution

by:
dmang earned 320 total points
ID: 8183565
how about this...

dim docrange as range
icharcount as integer

set docrange = activedocument.range

icharCount = DocRange.ComputeStatistics(Statistic:=wdStatisticCharacters)
0
 

Expert Comment

by:CleanupPing
ID: 9056541
zombieman:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9073927
Moderator, my recommended disposition is:

    Accept dmang's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

764 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