![]() |
|
#16
|
||||
|
||||
|
Having now seen what you're doing, I might add that all of the Find/Replace expressions I've provided could be rolled up into a single macro: Code:
Sub Demo()
With ActiveDocument.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Text = "([!^13]@^13)(*^13)([!^13]^13)([!^13]@^13)[!^13]@^13([!^13]@^13)"
.Replacement.Text = "AN \1AC \3AH \4AL \5\2"
.Execute Replace:=wdReplaceOne
.Text = "(DP )([!^13]{1,})([^13]VD*VX[!^13]{1,}[^13])(DP )([!^13]{1,}[^13])"
.Replacement.Text = "\1\2\3DB \2,\5\4\5"
.Execute Replace:=wdReplaceAll
.Text = "<Front[!0-9]{1,}"
.Replacement.Text = "**French border**^p"
.Execute Replace:=wdReplaceAll
End With
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#17
|
|||
|
|||
|
Thanks a lot for that,
But I'm now not too sure of input text for this lattest macro you've wrote me Because I can't get it working with this exemple: TMA LORRAINE partie 5 49º09’22”N,006º49’12”E -- Frontière franco--allemande -- 49º09’04”N,006º50’02”E -- 49º02’02”N,006º59’35”E -- 49º01’06”N,006º57’56”E -- arc horaire de 10NM de rayon centré sur 48º59’11”N,006º42’58”E (GTQ) -- 48º57’22”N,006º57’57”E -- 48º53’58”N,007º04’08”E -- 48º46’19”N,006º54’21”E -- 48º49’46”N,006º48’06”E -- arc horaire de 10NM de rayon centré sur 48º59’11”N,006º42’58”E (GTQ) -- 48º49’12”N,006º42’05”E -- 48º47’54”N,006º39’37”E -- 49º08’00”N,006º34’45”E -- 49º08’00”N,006º45’20”E -- 49º09’07”N,006º44’42”E -- arc horaire de 10NM de rayon centré sur 48º59’11”N,006º42’58”E (GTQ) -- 49º08’39”N,006º47’55”E -- 49º09’22”N,006º49’12”E D FL075 ------------ 4000ft AMSL |
|
#18
|
||||
|
||||
|
In what sense doesn't it work? Except for a possible issue with "Frontière franco--allemande", which gets changed to "**French border**", it works for me.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#19
|
|||
|
|||
|
I got an error "4198" executing it
Get stuck on : .Execute Replace:=wdReplaceOne |
|
#20
|
||||
|
||||
|
I can only produce that result by running the macro on a document in which the data in the first part of the document (ie the part to which 'TMA LORRAINE partie 5' applies) has already been reformatted.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#21
|
|||
|
|||
|
Which result?
Is your latest macro working for you with this text unformatted ? TMA LORRAINE partie 5 49º09’22”N,006º49’12”E -- Frontière franco--allemande -- 49º09’04”N,006º50’02”E -- 49º02’02”N,006º59’35”E -- 49º01’06”N,006º57’56”E -- arc horaire de 10NM de rayon centré sur 48º59’11”N,006º42’58”E (GTQ) -- 48º57’22”N,006º57’57”E -- 48º53’58”N,007º04’08”E -- 48º46’19”N,006º54’21”E -- 48º49’46”N,006º48’06”E -- arc horaire de 10NM de rayon centré sur 48º59’11”N,006º42’58”E (GTQ) -- 48º49’12”N,006º42’05”E -- 48º47’54”N,006º39’37”E -- 49º08’00”N,006º34’45”E -- 49º08’00”N,006º45’20”E -- 49º09’07”N,006º44’42”E -- arc horaire de 10NM de rayon centré sur 48º59’11”N,006º42’58”E (GTQ) -- 49º08’39”N,006º47’55”E -- 49º09’22”N,006º49’12”E D FL075 ------------ 4000ft AMSL |
|
#22
|
||||
|
||||
|
Yes. I run the macro against that and it outputs:
AN TMA LORRAINE partie 5 AC D AH FL075 AL 4000ft AMSL 49º09’22”N,006º49’12”E -- **French border** 49º09’04”N,006º50’02”E -- 49º02’02”N,006º59’35”E -- 49º01’06”N,006º57’56”E -- arc horaire de 10NM de rayon centré sur 48º59’11”N,006º42’58”E (GTQ) -- 48º57’22”N,006º57’57”E -- 48º53’58”N,007º04’08”E -- 48º46’19”N,006º54’21”E -- 48º49’46”N,006º48’06”E -- arc horaire de 10NM de rayon centré sur 48º59’11”N,006º42’58”E (GTQ) -- 48º49’12”N,006º42’05”E -- 48º47’54”N,006º39’37”E -- 49º08’00”N,006º34’45”E -- 49º08’00”N,006º45’20”E -- 49º09’07”N,006º44’42”E -- arc horaire de 10NM de rayon centré sur 48º59’11”N,006º42’58”E (GTQ) -- 49º08’39”N,006º47’55”E -- 49º09’22”N,006º49’12”E
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#23
|
|||
|
|||
|
Oh yes sorry
It works great. So your "10 lines" code does the same thing as my "200 lines".... Wildcards can be very powerful ! (Skills as well
|
|
#24
|
|||
|
|||
|
Hi Macropod,
Me again! Could you help me understand something I've now this Macro which works almost as I wish. Quote:
Quote:
Quote:
When I Copy/Paste from PDF file, I use "Paste without formating" Could you illuminate the situation for me? Thank you Marc. |
|
#25
|
||||
|
||||
|
It doesn't work on the second one because that one doesn't have a paragraph with only a single character before the 4100ft AMSL.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#26
|
|||
|
|||
|
ouch....
I'm so clueless... tx |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Macro to find text and replace with form field containing that text
|
iiiiifffff | Word VBA | 16 | 06-04-2016 01:47 AM |
| Macro to find text in between two characters and then format selected text? | qcom | Word | 5 | 02-19-2015 11:23 PM |
Need help on Macro 03- Find text - if text is blank then remove line
|
simpleonline1234 | Word VBA | 1 | 02-25-2011 02:28 AM |
Combobox manipulation
|
vsempoux | Word VBA | 3 | 10-31-2009 08:58 AM |
| Mail merge Field Code Manipulation | macjnr | Mail Merge | 0 | 09-10-2009 11:37 AM |