PDA

View Full Version : Issue with Macro in Word 2007



JRobinson22
01-13-2013, 11:44 AM
Hi - I'm trying to record a macro in Word 2007 that will select all paragraphs that begin with a number followed by period and a space (example: 6. , 7. ) and runs another macro on them which I have already recorded. I'm kind of new to this, so I was hoping someone more experienced here could help me. Attached is a sample of what I'm talking about, I want to automatically highlight each of the bolded paragraphs / run a another macro on them that I've recorded (the documents I'm working with can be really long so this would save me a lot of time). Any help would be much appreciated. thanks!

1. Please provide a complete list along with a sample of the reports the City will receive.

Please see Attachment XXX for reference.


2. Please describe your companies web based services for both members and plan administrators? Do you offer a web site to access tools for medical service and cost comparisons? Please describe.

Our award-winning public corporate Web site offers a user-friendly, task-driven and up-to-date looking site that includes these features:

JRobinson22
01-18-2013, 11:35 AM
Hi - Is there additional info needed in order for me to get a reply to this? Just curious if I'm leaving something out as most other posts seem to have at least 1 reply. thanks

gmaxey
01-19-2013, 11:37 PM
Sub ScratchMacro()
Dim oPar As Paragraph
Dim oRng As Word.Range
For Each oPar In ActiveDocument.Range.Paragraphs
If IsNumeric(oPar.Range.Characters(1)) Then
Set oRng = oPar.Range
oRng.Collapse wdCollapseStart
oRng.MoveEndUntil Cset:=" "
If oRng Like "[0-9]*." Then
oPar.Range.Select
'Run your code.
End If
End If
Next oPar
End Sub

JRobinson22
01-20-2013, 06:06 AM
Greg - It works! You are awesome, thanks so much.

Mind if I ask one more question? Can you let me know what code I could use to select all paragraphs and bulleted lists (any bullet style) which have exclusively Times New Roman font and move them over one indent?

Thanks again, you just saved me hours!

gmaxey
01-20-2013, 08:11 AM
J,

Something like this:

Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oPar As Word.Paragraph
For Each oPar In ActiveDocument.Paragraphs
If oPar.Range.Font.Name = "Times New Roman" Then
oPar.Indent
End If
Next oPar

End Sub

JRobinson22
01-20-2013, 11:06 AM
Greg - that worked perfectly - you're an f'ing genius!