<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: word count on page</title>
	<link>http://ask.metafilter.com/22109/word-count-on-page/</link>
	<description>Comments on Ask MetaFilter post word count on page</description>
	<pubDate>Wed, 03 Aug 2005 07:19:46 -0800</pubDate>
	<lastBuildDate>Wed, 03 Aug 2005 07:19:46 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: word count on page</title>
		<link>http://ask.metafilter.com/22109/word-count-on-page</link>	
		<description>So I&apos;m trying to write a Word macro to count how many words there are on the current page of the document. It&apos;s not going well. &lt;br /&gt;&lt;br /&gt; It&apos;s already taken me quite a while to figure out that the code to get the current page number is Selection.Information(wdActiveEndPageNumber) -- I mean, how intuitive is that? From there it seems that I&apos;d need to use Selection.MoveUp and Selection.MoveDown in a loop and make it stop and reverse when it finds page breaks, but I&apos;m at a loss as to how to do it.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2005:site.22109</guid>
		<pubDate>Wed, 03 Aug 2005 07:08:36 -0800</pubDate>
		<dc:creator>reklaw</dc:creator>
		
			<category>word</category>
		
			<category>macro</category>
		
			<category>wordcount</category>
		
	</item> <item>
		<title>By: oddman</title>
		<link>http://ask.metafilter.com/22109/word-count-on-page#355143</link>	
		<description>Why not just use the mouse (or shift-arrow keys) to select the words on the page and use the regular count tool.  It automatically restricts itself to the selected text.  (Well it does in my version of Word (2002))?&lt;br&gt;
&lt;br&gt;
Maybe I&apos;m missing something.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.22109-355143</guid>
		<pubDate>Wed, 03 Aug 2005 07:19:46 -0800</pubDate>
		<dc:creator>oddman</dc:creator>
	</item><item>
		<title>By: reklaw</title>
		<link>http://ask.metafilter.com/22109/word-count-on-page#355190</link>	
		<description>Well yeah, that&apos;d be fine if there was any shortcut key that meant &apos;Select All on Page&apos; (using Shift+PgUp/PgDn doesn&apos;t seem to respect page breaks at all). As far as I can tell, there&apos;s everything else, but no Select All on Page. A macro for that function would be just as good.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.22109-355190</guid>
		<pubDate>Wed, 03 Aug 2005 08:30:34 -0800</pubDate>
		<dc:creator>reklaw</dc:creator>
	</item><item>
		<title>By: boo_radley</title>
		<link>http://ask.metafilter.com/22109/word-count-on-page#355201</link>	
		<description>Cribbed from various sources. No warranties, express or implied, released into the public domain, etc, etc.&lt;br&gt;
Does not give wordcount for the very last page. This is left as an excercise for the reader.&lt;br&gt;
&lt;br&gt;
Sub getPageWordCount()&lt;br&gt;
&lt;br&gt;
   Dim iPgNum As Integer&lt;br&gt;
   Dim sPgNum As String&lt;br&gt;
   Dim ascChar As Integer&lt;br&gt;
   Dim rngPage As Range&lt;br&gt;
   Dim iBeginPage As Integer&lt;br&gt;
   Dim iEndPage As Integer&lt;br&gt;
   &apos; Go to start of document and make sure its paginated correctly.&lt;br&gt;
   Selection.HomeKey Unit:=wdStory, Extend:=wdMove&lt;br&gt;
   ActiveDocument.Repaginate&lt;br&gt;
&lt;br&gt;
   &apos; Loop through the number of pages in the document.&lt;br&gt;
   For iPgNum = 2 To Selection.Information(wdNumberOfPagesInDocument)&lt;br&gt;
      sPgNum = CStr(iPgNum)&lt;br&gt;
      iBeginPage = Selection.start&lt;br&gt;
      &apos; Go to next page&lt;br&gt;
      Selection.GoTo wdGoToPage, wdGoToAbsolute, sPgNum&lt;br&gt;
      &apos; and to the last character of the previous page...&lt;br&gt;
      Selection.MoveLeft wdCharacter, 1, wdMove&lt;br&gt;
      iEndPage = Selection.start&lt;br&gt;
      &apos; Retrieve the character code at insertion point.&lt;br&gt;
      Set rngPage = ActiveDocument.Range(iBeginPage, iEndPage)&lt;br&gt;
      MsgBox rngPage.ComputeStatistics(wdStatisticWords)&lt;br&gt;
      &apos; Check the character code for hard page break or text.&lt;br&gt;
   Next&lt;br&gt;
&lt;br&gt;
End Sub</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.22109-355201</guid>
		<pubDate>Wed, 03 Aug 2005 08:41:56 -0800</pubDate>
		<dc:creator>boo_radley</dc:creator>
	</item><item>
		<title>By: reklaw</title>
		<link>http://ask.metafilter.com/22109/word-count-on-page#355219</link>	
		<description>Well, that solution didn&apos;t quite work right (it looped through each page instead of just counting the current page). It did show me how the GoTo function worked, though, which let me figure out that this modified version would work:&lt;br&gt;
&lt;br&gt;
Sub getPageWordCount()&lt;br&gt;
&lt;br&gt;
Dim rngPage As Range&lt;br&gt;
Dim iBeginSel As Integer&lt;br&gt;
Dim iEndSel As Integer&lt;br&gt;
Dim iCurrentPage As Integer&lt;br&gt;
Dim iNextPage As Integer&lt;br&gt;
&lt;br&gt;
iCurrentPage = Selection.Information(wdActiveEndPageNumber)&lt;br&gt;
Selection.GoTo wdGoToPage, wdGoToAbsolute, iCurrentPage&lt;br&gt;
iBeginSel = Selection.Start&lt;br&gt;
&lt;br&gt;
iNextPage = iCurrentPage + 1&lt;br&gt;
Selection.GoTo wdGoToPage, wdGoToAbsolute, iNextPage&lt;br&gt;
Selection.MoveLeft wdCharacter, 1, wdMove&lt;br&gt;
iEndSel = Selection.Start&lt;br&gt;
&lt;br&gt;
Set rngPage = ActiveDocument.Range(iBeginSel, iEndSel)&lt;br&gt;
MsgBox rngPage.ComputeStatistics(wdStatisticWords) &amp;amp; &quot; words.&quot;, vbOKOnly, &quot;Word Count for Page&quot;&lt;br&gt;
&lt;br&gt;
End Sub&lt;br&gt;
&lt;br&gt;
Thanks for your help.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.22109-355219</guid>
		<pubDate>Wed, 03 Aug 2005 09:10:29 -0800</pubDate>
		<dc:creator>reklaw</dc:creator>
	</item><item>
		<title>By: whatisish</title>
		<link>http://ask.metafilter.com/22109/word-count-on-page#355262</link>	
		<description>FYI - that modified source appears to generated an error if you are currently on the last page.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.22109-355262</guid>
		<pubDate>Wed, 03 Aug 2005 09:50:22 -0800</pubDate>
		<dc:creator>whatisish</dc:creator>
	</item><item>
		<title>By: Capn</title>
		<link>http://ask.metafilter.com/22109/word-count-on-page#355312</link>	
		<description>&lt;a href=&quot;http://www.sfwriter.com/ow06.htm&quot;&gt;Are you sure you want to know the exact number of words?&lt;/a&gt; (second last paragraph).</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.22109-355312</guid>
		<pubDate>Wed, 03 Aug 2005 11:10:54 -0800</pubDate>
		<dc:creator>Capn</dc:creator>
	</item><item>
		<title>By: whatisish</title>
		<link>http://ask.metafilter.com/22109/word-count-on-page#355463</link>	
		<description>Borrowing from those before me... this works (terribly sloppy, I know - I really dont know what I&apos;m doing here) and doesn&apos;t generate an error on the last page.  It also assumes that no page can have more than 2000 characters.  &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Sub CountWordsonPage()&lt;br&gt;
&lt;br&gt;
Dim rngPage As Range&lt;br&gt;
Dim iBeginSel As Integer&lt;br&gt;
Dim iEndSel As Integer&lt;br&gt;
Dim iCurrentPage As Integer&lt;br&gt;
Dim iNextPage As Integer&lt;br&gt;
&lt;br&gt;
&apos; Mark the beginning of current page&lt;br&gt;
iCurrentPage = Selection.Information(wdActiveEndPageNumber)&lt;br&gt;
Selection.GoTo wdGoToPage, wdGoToAbsolute, iCurrentPage&lt;br&gt;
iBeginSel = Selection.Start&lt;br&gt;
&lt;br&gt;
&apos; Mark the end of current page&lt;br&gt;
Do Until iCurrentPage &lt;&gt; Selection.Information(wdActiveEndPageNumber) Or x = 2000&lt;br&gt;
Selection.MoveRight wdCharacter, 1, wdMove&lt;br&gt;
x = x + 1&lt;br&gt;
Loop&lt;br&gt;
iEndSel = Selection.Start&lt;br&gt;
&lt;br&gt;
&apos; Count Words&lt;br&gt;
Set rngPage = ActiveDocument.Range(iBeginSel, iEndSel)&lt;br&gt;
MsgBox rngPage.ComputeStatistics(wdStatisticWords) &amp;amp; &quot; words.&quot;, vbOKOnly, &quot;Word Count for Page&quot;&lt;br&gt;
&lt;br&gt;
&apos; Puts cursor back at the top of the original page.  &lt;br&gt;
&apos; What would be nice is to mark the original cursor &lt;br&gt;
&apos; location and return it to that location instead.&lt;br&gt;
If iCurrentPage = Selection.Information(wdActiveEndPageNumber) Then&lt;br&gt;
    Selection.GoTo wdGoToPage, wdGoToAbsolute, iCurrentPage&lt;br&gt;
Else&lt;br&gt;
    Selection.GoTo wdGoToPage, wdGoToAbsolute, iCurrentPage - 1&lt;br&gt;
End If&lt;br&gt;
    &lt;br&gt;
End Sub&lt;/&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.22109-355463</guid>
		<pubDate>Wed, 03 Aug 2005 14:00:46 -0800</pubDate>
		<dc:creator>whatisish</dc:creator>
	</item>
	</channel>
</rss>
