#1
|
|||
|
|||
Format text automatically
Hi, I would like to do the following automated task on Word 2003:
THROUGH THE WHOLE DOCUMENT: WHENEVER: There is a line starting with "Nº" AND There is a "/" in any place within the first 9 characters on this line THEN: Look for a new paragraph starting with "Obs.:" OR "Justificativa:" and add this paragraph to the previous one, keeping right and left margins justified. If none of these words are found, do nothing. Thanks in advance. EXAMPLE: Before ------ Nº 3631/2013 - fazer tubulação para desvio de água fluvial nos fundos do terreno, na Rua Ricardo Althoff, no Bairro Passo Manso. Obs: maiores informações com Sr. Norberto, pelo telefone 9239-7754 ou com Sr. Jorge, pelo telefone 9968-9788. Nº 3632/2013 ... After ----- Nº 3631/2013 - fazer tubulação para desvio de água fluvial nos fundos do terreno, na Rua Ricardo Althoff, no Bairro Passo Manso. Obs: maiores informações com Sr. Norberto, pelo telefone 9239-7754 ou com Sr. Jorge, pelo telefone 9968-9788. Nº 3632/2013 ... |
#2
|
||||
|
||||
As a once-off exercise, you could do this using a wildcard Find/Replace, where:
Find = (Nº [0-9]{1,8}/[!^13]{1,})[^13]([OJ][bu]s[.:ifcatv]{1,13}) Replace = \1 \2
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
It didn´t work. Nothing was found.
|
#4
|
||||
|
||||
Did you check the 'use wildcards' option?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Sorry, forgot to do it.
Anyway, now Word issues the following error message (translated from Portuguese): The text in 'Find' has an expression not valid for the matching pattern. |
#6
|
||||
|
||||
In that case, change the three Find commas ',' to semi-colons ';'.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Nothing was found!
The document has some text exactly as follows: -------------- Nº 3651/2013 - realizar manutenção na iluminação da Rua Aconcágua, no Bairro Fortaleza Alta. Justificativa: as lâmpadas estão no local, mas não funcionam. Obs: maiores informações com Andréia, pelo telefone 8424-2143. |
#8
|
||||
|
||||
Can you attach a document to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Added two attachments, showing the original text and how it must be formatted.
Thank you. |
#10
|
||||
|
||||
The problem is that you have empty paragraphs between your lines. The second line is not the next paragraph as per your original post! Try:
Find = (Nº [0-9]{1;8}/[!^13]{1;})[^13]{1;}([OJ][bu]s[.:ifcatv]{1;13}) Replace = \1 \2
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
Wow! Now that worked!
Well maybe needs some fine tuning.. 1) When there are 'Obs' and 'Justificativa' in the same paragraph, it only does the formatting for the first one. Then I would need to do find/replace again to format the second one. Is there a way to do it in only one step? (see attachaed files) 2) In the attached file PT_BEFORE, the code won´t work for the last 'Obs' (last line of the document). Can you see why? Thanks! |
#12
|
||||
|
||||
Quote:
Quote:
Find = (Nº [0-9]{1;8}/[!^13]@)[^13]{1;}([OJ][bu]s[.:ifcatv]{1;13})
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#13
|
|||
|
|||
It worked great!
Unfortunately, I´ve come across some paragraph types that may happen a lot, just as in the attached files. The rules are, for each line starting with: "DO VEREADOR AAAA" or "DOS VEREADORES AAAA, BBBB" or "DA VEREADORA CCCC" And the next line below is: "Nº X/YYYY - " (where X can be any number of 1 to 5 digits) No additional spaces or blank lines should appear. A good example in the attached files. A million thanks ! Last edited by dexter30; 04-16-2013 at 05:33 PM. |
#14
|
||||
|
||||
How does one know that the series following your Do(s) Vereador(a/es) line has ended? It has to be something that can be programmed.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#15
|
|||
|
|||
The series following "Do(s) Vereador(a/es)" ends when the next "Do(s) Vereador(a/es)" is found.
Let me put it this way: Rule: anything between two entries of the text below must have no extra spaces or blank lines. DO(S) VEREADOR(A/ES) NAME1 (NAME2, NAME3, ..., AND NAMEX) Nº X/YYYY - Exception: threre must be a blank line before each paragraph starting with DO(S) VEREADOR(A/ES) Example: BEFORE -------- REQUERIMENTOS DO VEREADOR FULANO DE TAL Nº 123/2013 - providências juntos ao Executivo Municipal, no sentido de que responda ao seguinte pedido de informação: quando irá patrolar e macadamizar a Rua Rio Bonito, em toda a sua extensão? Enviar: - cronograma da obra; - questão de ordem; - todos os mapas; - outras observações afins. Prazo de no máximo 30 dias. DOS VEREADORES CICRANO DE TAL E BELTRANO ALGUEM Nº 1000/2013 - ... ... ... AFTER ------ REQUERIMENTOS DO VEREADOR FULANO DE TAL Nº 15/2013 - providências juntos ao Executivo Municipal, no sentido de que responda ao seguinte pedido de informação: quando irá patrolar e macadamizar a Rua Rio Bonito, em toda a sua extensão? Enviar: - cronograma da obra; - questão de ordem; - todos os mapas; - outras observações afins. Prazo de no máximo 30 dias. DOS VEREADORES CICRANO DE TAL E BELTRANO ALGUEM Nº 1000/2013 - ... ... ... |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to find text in between two characters and then format selected text? | qcom | Word | 5 | 02-19-2015 11:23 PM |
automatically format meetings by me with some attendee | wsw70 | Outlook | 0 | 06-24-2011 12:16 AM |
Objective: Automatically export email text,attachment text to DB friendly format | SilentLee | Outlook | 0 | 11-14-2010 02:45 PM |
automatically extract footnotes into new file and apply character format to footnote | hrdwa | Word | 0 | 02-27-2010 03:16 AM |
format cells to automatically place quotes around text | dirtleg | Excel | 1 | 09-16-2008 01:52 PM |