Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-13-2012, 07:42 AM
krishnaoptif krishnaoptif is offline how to know word number by VBA Windows XP how to know word number by VBA Office 2007
Novice
how to know word number by VBA
 
Join Date: May 2012
Posts: 23
krishnaoptif is on a distinguished road
Default

i need count of words from document start to before "AN CC" containt...



Let say... i have 10 or 15 or more pages before "AN CC" then i need count of all above page's words count till "AN CC" Containt.. not after this...
Reply With Quote
  #2  
Old 08-13-2012, 08:01 AM
Venky62 Venky62 is offline how to know word number by VBA Windows 7 64bit how to know word number by VBA Office 2010 32bit
Advanced Beginner
 
Join Date: Jul 2012
Posts: 58
Venky62 is on a distinguished road
Default

Okay here is the code. I am assuming you know how to enter the code.
I have used "AN CC" as the search string - from the example you gave. A message box gives you the total number of words before this string. You can modify this code to do with it whatever you want.

Code:
Sub countwords()

    Dim intcount As Integer

    Selection.HomeKey Unit:=wdStory, Extend:=wdMove

    With Selection.Find
        .Text = "AN CC"
        .Forward = True
        .Wrap = wdFindStop
        .Execute
    End With

    Selection.HomeKey Unit:=wdStory, Extend:=wdExtend


    intcount = Selection.Words.Count

    Call MsgBox("The total number of words before AN CC are " & intcount, vbExclamation, Application.Name)

End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to know word number by VBA generating a number in Word John P Word 1 05-31-2012 10:29 PM
how to know word number by VBA auto number in word expert4knowledge Word 7 05-31-2012 02:37 PM
how to know word number by VBA Mailing: how to make the "page number" in Word is the same as "row number" in excel w Jamal NUMAN Word 1 09-03-2011 11:37 AM
Textbox Number changes when I open Word t0m46 Word VBA 0 09-07-2010 05:46 AM
Number formatting in Word table 8braitp Word Tables 0 08-27-2009 04:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:47 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft