?
Solved

Character count in Word doc

Posted on 2003-03-05
4
Medium Priority
?
248 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
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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

599 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