Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2013, 10:20 AM
dexter30 dexter30 is offline Format text automatically Windows Vista Format text automatically Office 2003
Novice
Format text automatically
 
Join Date: Apr 2013
Posts: 20
dexter30 is on a distinguished road
Default 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 ...
Reply With Quote
  #2  
Old 04-11-2013, 12:45 PM
macropod's Avatar
macropod macropod is offline Format text automatically Windows 7 64bit Format text automatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 04-12-2013, 05:08 AM
dexter30 dexter30 is offline Format text automatically Windows Vista Format text automatically Office 2003
Novice
Format text automatically
 
Join Date: Apr 2013
Posts: 20
dexter30 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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
It didn´t work. Nothing was found.
Reply With Quote
  #4  
Old 04-12-2013, 05:09 AM
macropod's Avatar
macropod macropod is offline Format text automatically Windows 7 64bit Format text automatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Did you check the 'use wildcards' option?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 04-12-2013, 05:14 AM
dexter30 dexter30 is offline Format text automatically Windows Vista Format text automatically Office 2003
Novice
Format text automatically
 
Join Date: Apr 2013
Posts: 20
dexter30 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Did you check the 'use wildcards' option?
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.
Reply With Quote
  #6  
Old 04-12-2013, 05:55 AM
macropod's Avatar
macropod macropod is offline Format text automatically Windows 7 64bit Format text automatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In that case, change the three Find commas ',' to semi-colons ';'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 04-12-2013, 06:05 AM
dexter30 dexter30 is offline Format text automatically Windows Vista Format text automatically Office 2003
Novice
Format text automatically
 
Join Date: Apr 2013
Posts: 20
dexter30 is on a distinguished road
Default

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.
Reply With Quote
  #8  
Old 04-12-2013, 06:13 AM
macropod's Avatar
macropod macropod is offline Format text automatically Windows 7 64bit Format text automatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #9  
Old 04-12-2013, 06:19 AM
dexter30 dexter30 is offline Format text automatically Windows Vista Format text automatically Office 2003
Novice
Format text automatically
 
Join Date: Apr 2013
Posts: 20
dexter30 is on a distinguished road
Default

Added two attachments, showing the original text and how it must be formatted.

Thank you.
Attached Files
File Type: doc DOC_TEXT_BEFORE.doc (24.0 KB, 10 views)
File Type: doc DOC_TEXT_AFTER.doc (24.0 KB, 7 views)
Reply With Quote
  #10  
Old 04-12-2013, 07:25 AM
macropod's Avatar
macropod macropod is offline Format text automatically Windows 7 64bit Format text automatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #11  
Old 04-15-2013, 10:11 AM
dexter30 dexter30 is offline Format text automatically Windows Vista Format text automatically Office 2003
Novice
Format text automatically
 
Join Date: Apr 2013
Posts: 20
dexter30 is on a distinguished road
Default

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!
Attached Files
File Type: doc PT_BEFORE.DOC (20.5 KB, 10 views)
File Type: doc PT_AFTER.DOC (20.5 KB, 8 views)
Reply With Quote
  #12  
Old 04-15-2013, 06:44 PM
macropod's Avatar
macropod macropod is offline Format text automatically Windows 7 64bit Format text automatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by dexter30 View Post
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?
The simplest way of dealing with this is to simply click 'ReplaceAll' again. Finding either or both paragraphs can't be done in one pass - even with a macro, I'd do it in two passes.
Quote:
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?
Basically, it's an issue related to the length of the first paragraph. Try:
Find = (Nº [0-9]{1;8}/[!^13]@)[^13]{1;}([OJ][bu]s[.:ifcatv]{1;13})
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 04-16-2013, 09:06 AM
dexter30 dexter30 is offline Format text automatically Windows Vista Format text automatically Office 2003
Novice
Format text automatically
 
Join Date: Apr 2013
Posts: 20
dexter30 is on a distinguished road
Default

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 !
Attached Files
File Type: doc PAUTA_DUVIDA_BEFORE2.doc (20.0 KB, 9 views)
File Type: doc PAUTA_DUVIDA_AFTER2.doc (20.0 KB, 8 views)

Last edited by dexter30; 04-16-2013 at 05:33 PM.
Reply With Quote
  #14  
Old 04-18-2013, 12:43 AM
macropod's Avatar
macropod macropod is offline Format text automatically Windows 7 64bit Format text automatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #15  
Old 04-18-2013, 08:00 AM
dexter30 dexter30 is offline Format text automatically Windows Vista Format text automatically Office 2003
Novice
Format text automatically
 
Join Date: Apr 2013
Posts: 20
dexter30 is on a distinguished road
Default

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 - ... ... ...
Reply With Quote
Reply



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

Other Forums: Access Forums

All times are GMT -7. The time now is 02:14 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft