M-Unit
01-30-2008, 11:30 AM
Hello!
I've just spent 6 hours trying to make a Macro work, and what I can't get it to do is loop.
I'm really hoping somebody can help me ? VBA is not my forte and the life is dribbling out of me...
What I have is a big MS Word text document for editing.
Each paragraph is tabbed.
I need to remove the tab and apply formatting to the paragraph following the tab (first line indent & double line height).
I started by using the Macro Recorder, and this works:
Sub ReplaceTab()
'
' ReplaceTab Macro
' Macro recorded 30/1/08
'
Selection.WholeStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^t"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.TypeBackspace
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 6
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphJustify
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(1.27)
.OutlineLevel = wdOutlineLevelBodyText
End With
End Sub
But in order to insert a loop step (apart from actually needing to know how!) I have to edit the recorded script, and this is where I've fallen apart.
I could insert about five failed attempts to incorporate DO variants, but they're all embarrassing failures...
If you can help you will be giving somebody (ie Me) the gift of life (returned) and hopefully in the long term a reduction in RSI !!!
Many thanks in advance.
MU
I've just spent 6 hours trying to make a Macro work, and what I can't get it to do is loop.
I'm really hoping somebody can help me ? VBA is not my forte and the life is dribbling out of me...
What I have is a big MS Word text document for editing.
Each paragraph is tabbed.
I need to remove the tab and apply formatting to the paragraph following the tab (first line indent & double line height).
I started by using the Macro Recorder, and this works:
Sub ReplaceTab()
'
' ReplaceTab Macro
' Macro recorded 30/1/08
'
Selection.WholeStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^t"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.TypeBackspace
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 6
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphJustify
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(1.27)
.OutlineLevel = wdOutlineLevelBodyText
End With
End Sub
But in order to insert a loop step (apart from actually needing to know how!) I have to edit the recorded script, and this is where I've fallen apart.
I could insert about five failed attempts to incorporate DO variants, but they're all embarrassing failures...
If you can help you will be giving somebody (ie Me) the gift of life (returned) and hopefully in the long term a reduction in RSI !!!
Many thanks in advance.
MU