# Word macro experts needed - for SIMPLE problem!

**URL:** <https://boards.straightdope.com/t/word-macro-experts-needed-for-simple-problem/264072>\
**Category:** Factual Questions\
**Created:** [September 11, 2004, 9:06pm UTC](https://boards.straightdope.com/t/word-macro-experts-needed-for-simple-problem/264072 "2004-09-11T21:06:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![istara](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@istara](https://boards.straightdope.com/u/istara)\
**Post date:** [September 11, 2004, 9:06pm UTC](https://boards.straightdope.com/t/word-macro-experts-needed-for-simple-problem/264072/1 "2004-09-11T21:06:17Z")

</div>

This should be the simplest thing, but it is not working (perhaps because I’m using a Mac?)

I am trying to make a Macro in MS Word that creates a button that when I press it, does the Tools: Word Count function. I have done this in the past on a PC with no problem. However, despite trying to record the action, the resulting macro is blank:

> [@](#):
>
> \*\*Sub IstaraWordCount()  
> ’  
> ’ IstaraWordCount Macro  
> ’ Macro recorded 12/9/04 by Istara  
> ’
> 
> End Sub\*\*

If I just knew what the syntax/command is for Word Count I could edit it in manually, only I don’t. The Visual Basic help doesn’t seem to be installed, and nowhere on the internet can I find a list of simple commands. Googling “Word count macro” and similar keeps throwing up results for some downloadable program, which isn’t what I want (nor will it work on my Mac).

If anyone can help I would be exremely grateful!

---

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [September 11, 2004, 9:27pm UTC](https://boards.straightdope.com/t/word-macro-experts-needed-for-simple-problem/264072/2 "2004-09-11T21:27:49Z")

</div>

This isn’t a way to actually activate the word count function in the tools menu but it’s what I’ve come up with so far…

MsgBox (ActiveDocument.Words.Count)

---

<div class="post-metadata">

**Author:** ![istara](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@istara](https://boards.straightdope.com/u/istara)\
**Post date:** [September 11, 2004, 9:34pm UTC](https://boards.straightdope.com/t/word-macro-experts-needed-for-simple-problem/264072/3 "2004-09-11T21:34:00Z")

</div>

Oh that is kewl - thanks! I substituted ActiveDocument for Selection and it does exactly what I want!

How do you find out the syntax/commands in the first place? If I could find a simple list, with some examples of very basic macros, I could do so much more. (As the Record function isn’t working I sadly can’t create any basic ones myself to pick apart and fiddle with).

Thanks SO much 😉

---

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [September 11, 2004, 9:41pm UTC](https://boards.straightdope.com/t/word-macro-experts-needed-for-simple-problem/264072/4 "2004-09-11T21:41:51Z")

</div>

I’m _very_ rusty on VB. for instance I would put some words like “there are " before and " words in the selection” after, but I don’t know how to join strings in vb (I know quite well in C++)

I found the answer just by messing about with word. I did a search for ‘count’ and eventually found that. I have a feeling it might not be possible to run word’s own word count dialog but I could easily be wrong.

---

<div class="post-metadata">

**Author:** ![counsel\_wolf](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@counsel\_wolf](https://boards.straightdope.com/u/counsel_wolf)\
**Post date:** [September 11, 2004, 9:43pm UTC](https://boards.straightdope.com/t/word-macro-experts-needed-for-simple-problem/264072/5 "2004-09-11T21:43:58Z")

</div>

> [@istara](#):
>
> Oh that is kewl - thanks! I substituted ActiveDocument for Selection and it does exactly what I want!
> 
> How do you find out the syntax/commands in the first place? If I could find a simple list, with some examples of very basic macros, I could do so much more. (As the Record function isn’t working I sadly can’t create any basic ones myself to pick apart and fiddle with).
> 
> Thanks SO much 😉

Not to nitpick **Lobsang’s** method too much (it was my first attempt as well) but it counts punctuation and spaces as words too, which may throw off your stats.

I suggest something along the lines of:

Public Sub view\_WC()  
MsgBox “There are " & ActiveDocument.ComputeStatistics(wdStatisticWords) & " words.”  
End Sub

which I found by looking in Tools-\>macros-\>macros in (word commands) noting that ToolsWordCount did what I wanted and typing that into the VB help, which gave me the code above. A mine of useful info that particular method.

The example above works under Word 2003, I don’t have another machine about with an older version to test on, sorry.

---

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [September 11, 2004, 9:46pm UTC](https://boards.straightdope.com/t/word-macro-experts-needed-for-simple-problem/264072/6 "2004-09-11T21:46:03Z")

</div>

P.s. the record macro did the same thing for me, so I don’t think it’s because you are on a Mac.
