#1
|
|||
|
|||
Help with macro - inserting tab
I've run into a problem with a macro I have developed (with help from very kind people on here also). Please see image of before and after the macro is run.
The macro should insert a tab at the beginning of paragraphs that start with (a), (i) (1), a), 1), 100 etc. The macro runs fine except when the paragraph starts with a number. Can anyone help with the code below to insert a tab before a number (please note this is just an extract from the main macro). Thanks, Shelley Code:
'insert tab at beginning of paragraph with a bracket e.g. (a), (i), (1) With oRng.Find .Text = "^p(" .Replacement.Text = "^p^t(" .Execute Replace:=wdReplaceAll End With 'insert tab at beginning of paragraph e.g a), 1), i), 100 etc. With oRng.Find .Text = "[^p]\([a-zA-Z0-9][)]" .Replacement.Text = "^p^t" .Execute Replace:=wdReplaceAll End With |
#2
|
||||
|
||||
It appears from your illustrations that you want to begin every paragraph with a tab thus
Code:
With orng.Find .MatchWildcards = False .Text = "^p" .Replacement.Text = "^p^t" .Execute Replace:=wdReplaceAll End With Code:
'insert tab at beginning of paragraph with a bracket e.g. (a), (i), (1) With orng.Find .MatchWildcards = True .Text = "^13(\([a-z0-9]{1,}\))" .Replacement.Text = "^p^t\1" .Execute Replace:=wdReplaceAll End With 'insert tab at beginning of paragraph e.g a), 1), i), 100 etc. With orng.Find .MatchWildcards = True .Text = "^13([a-z0-9\)]{1,})" .Replacement.Text = "^p^t\1" .Execute Replace:=wdReplaceAll End With
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Help with macro - inserting tab
Hi Graham, the second option works perfectly, thank you very much again for your help, much appreciate, best wishes Shelley
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Is it possible to make a macro for inserting a 'division box?' | Rayroshi | Word | 1 | 08-30-2018 06:40 PM |
Macro-inserting text box | BLUEPUPIL | Word VBA | 14 | 04-16-2018 06:59 AM |
Macro for inserting and formatting headers and footers | Mike_Lennox | Word VBA | 4 | 10-06-2016 12:10 AM |
Need Macro for Find and Replace, Inserting logo in Ms-Word. | Aswinraj | Word VBA | 1 | 06-05-2016 04:33 PM |
Inserting key strokes with a macro line | ACA | Word VBA | 4 | 12-03-2012 04:40 AM |