Hello Greg,
The Scratch macro works great but I may eventually creat a style as
you suggested as soon as I learn a little more.
The Keyword macro works great with one exception. Is there a way to
have it add a blank line after the message is inserted at the
bookmark? Right now, unless I manually insert two blank lines
between the date and the body of the document the tope of the
document looks something like this: Check Your Baggage Here
Matthew 11:28-30
August 22, 2009
Keyword for today, Baggage, is Used 36 Times
Come to Me, all who are weary and heavy-laden, and I will give you
rest. Take My yoke upon you, and learn from Me, for I am gentle and
humble in heart; and you shall find rest for your souls. For My yoke
is easy, and My load is light." (Matthew 11:28-30)
I can live with it the way it is but it would be nice to automate
the whole process.
I reallu appreciate your time and assistance.
Michael
Reverend Burns,
You are welcome.
The solution you seek for your first question doesn't really not
require a macro. If I understand you correctly, you have the habit
of pressing enter twice to place a blank paragraph between your
current text paragraph and a new text paragraph and then you want
to format that empty paragraph with font size 6. A better approach
would be to create a paragraph style for your sermon notes that
uses Times New Roman 16 pt and 6 points of space after the
paragraph. Hit the enter key once to start a new paragraph.
However, if you really want to stick with your current method you
could use: Sub ScratchMacro()
Dim oPar As Paragraph
For Each oPar In ActiveDocument.Range.Paragraphs
If Len(oPar.Range.Text) = 1 Then
oPar.Range.Font.Size = 8
End If
Next oPar
End Sub
For the second request you could use something like this:
Sub ScratchKeyWordMacro()
Dim oRNg As Word.Range
Dim i As Long
Dim pWord As String
Set oRNg = ActiveDocument.Range
pWord = InputBox("Enter the keyword:", "Key Word")
With oRNg.Find
.Text = pWord
.MatchCase = False
.MatchWholeWord = True
While .Execute
i = i + 1
oRNg.Collapse wdCollapseEnd
Wend
End With
Set oRNg = ActiveDocument.Bookmarks("Keyword").Range
oRNg.Text = "Keyword for today, " & pWord & ", is Used " & i & "
Times"
ActiveDocument.Bookmarks.Add "Keyword", oRNg
End Sub
Use the Ribbon Insert Tab, Links Group, Bookmarks control to insert
a bookmark exactly where you want the results to appear. Name the
bookmark "Keyword"
Good luck.
Greg Maxey - Word MVP
My web site
http://gregmaxey.mvps.org
Hello Greg,
Thanks for the macro Help. I'll give it a try when I get back ri
rhe office on Tuesday.
Could I impose on you again for help with two more macros that
would make my work simpler?
First, because of failing eyesite I have set my default font and
font size on all documents to Times Romans, 16pt which makes my
notes very readable. However, I routinely go through my completed
documents and change the font size between paragraphs to 6pt. Can
a macro be made to do this automaticully?
Second, when teaching a class or preaching, I have for years
picked a key word from my notes and encouraged the children
(although I have found the adults get involved as well) to count
how often I use the word in my message or lesson. I then give the
child who comes the closest to the key word count in my manuscript
a prize, usually a candy bar or the likes. This had greatly
incread how much the children, and even the adults, pay attention.
Prior to upgrading from Word 2000 to Word 2007 I used a macro that
someone, I've forgotten who, made for me that would open a dialog
box that would ask for the key word and then scan the document and
give me a total of how many times that word was used in the notes.
However, I no longer have the macro (forgot to save the code) when
I did a clean install on my system at the same time I updated to
Office 2007. Could you help in this macro as well with one change
if it possible?
After entering the key word in the dialog box and having the macro
scan my document for the times the key word is used, instead of
displaying the total count in a message box like the old macro
used to, if possible I'd like to have the macro incert a line in
my document that would say something like "Key Word for Today,
XXX, is Used YYY Times" where XXX is the Key Word and YYY is the
number of times it is used. I always start my notes with three
lines, centered in bold print, which are the sermon or lesson
title, the text under study, and the date. I'd like the line
inserted in bold print and centered after the date which would
mean at the fourth line. If this could be done, I'd really
appreaciate it. If not I could live with the way the old macro
worked. I know this is a lot to ask but I'm dumber than an oyster win
it
comes to coding macros.
Any help would be greatly appreciated and thanks again for the
italicised quote macro.
Pastor Burns
Rev. Burns:
Sub WordsInQuotes()
Dim myRange As Range
Dim myString As String
Set myRange = ActiveDocument.Range
With myRange
Do While
.Find.Execute(FindText:="[^0147^01486^34][A-Za-z]{1,}[^0147^01486^34
]"
, _
MatchWildcards:=True, Wrap:=wdFindStop,
Forward:=True) = True
'.MoveStart Unit:=wdCharacter, Count:=1
'.MoveEnd Unit:=wdCharacter, Count:=-1
.Font.Italic = True
.Collapse Direction:=wdCollapseEnd
Loop
End With
Set myRange = Nothing
End Sub
The code includes the quotation marks making them italic as well.
I you just want the text (i.e., leave the marks themselves alone)
then remove the stet marks ' from the the two Move lines.