Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 03-10-2013, 04:31 PM
macropod's Avatar
macropod macropod is offline Text manipulation in MACRO Windows 7 64bit Text manipulation in MACRO Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,384
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

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]
Reply With Quote
  #17  
Old 03-10-2013, 04:42 PM
srt srt is offline Text manipulation in MACRO Windows 8 Text manipulation in MACRO Office 2010 64bit
Novice
Text manipulation in MACRO
 
Join Date: Mar 2013
Location: Glasgow, UK
Posts: 15
srt is on a distinguished road
Default

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
Reply With Quote
  #18  
Old 03-10-2013, 04:58 PM
macropod's Avatar
macropod macropod is offline Text manipulation in MACRO Windows 7 64bit Text manipulation in MACRO Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,384
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 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]
Reply With Quote
  #19  
Old 03-10-2013, 05:04 PM
srt srt is offline Text manipulation in MACRO Windows 8 Text manipulation in MACRO Office 2010 64bit
Novice
Text manipulation in MACRO
 
Join Date: Mar 2013
Location: Glasgow, UK
Posts: 15
srt is on a distinguished road
Default

I got an error "4198" executing it
Get stuck on : .Execute Replace:=wdReplaceOne
Reply With Quote
  #20  
Old 03-10-2013, 05:23 PM
macropod's Avatar
macropod macropod is offline Text manipulation in MACRO Windows 7 64bit Text manipulation in MACRO Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,384
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

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]
Reply With Quote
  #21  
Old 03-10-2013, 05:35 PM
srt srt is offline Text manipulation in MACRO Windows 8 Text manipulation in MACRO Office 2010 64bit
Novice
Text manipulation in MACRO
 
Join Date: Mar 2013
Location: Glasgow, UK
Posts: 15
srt is on a distinguished road
Default

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
Reply With Quote
  #22  
Old 03-10-2013, 06:26 PM
macropod's Avatar
macropod macropod is offline Text manipulation in MACRO Windows 7 64bit Text manipulation in MACRO Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,384
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

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]
Reply With Quote
  #23  
Old 03-11-2013, 03:42 AM
srt srt is offline Text manipulation in MACRO Windows 8 Text manipulation in MACRO Office 2010 64bit
Novice
Text manipulation in MACRO
 
Join Date: Mar 2013
Location: Glasgow, UK
Posts: 15
srt is on a distinguished road
Default

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
Reply With Quote
  #24  
Old 03-13-2013, 12:37 PM
srt srt is offline Text manipulation in MACRO Windows 8 Text manipulation in MACRO Office 2010 64bit
Novice
Text manipulation in MACRO
 
Join Date: Mar 2013
Location: Glasgow, UK
Posts: 15
srt is on a distinguished road
Default

Hi Macropod,
Me again!
Could you help me understand something
I've now this Macro which works almost as I wish.
Quote:
Sub Mise_en_Forme()
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 = "** \1AC \3AN \1AH \4AL \5\2"
.Execute Replace:=wdReplaceOne
.Text = "\(*\)"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = " -- "
.Replacement.Text = "^13"
.Execute Replace:=wdReplaceAll
.Text = "-- "
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = "--"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = " --"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = "(arc h)"
.Replacement.Text = "V D=+^13"
.Execute Replace:=wdReplaceAll
.Text = "(arc antih)"
.Replacement.Text = "V D=-^13"
.Execute Replace:=wdReplaceAll
.Text = "<o*r>"
.Replacement.Text = "V X"
.Execute Replace:=wdReplaceAll
.Text = "[X]^13"
.Replacement.Text = "X "
.Execute Replace:=wdReplaceAll
.Text = "([^13])([0-9])"
.Replacement.Text = "\1DP \2"
.Execute Replace:=wdReplaceAll
.Text = "º"
.Replacement.Text = ":"
.Execute Replace:=wdReplaceAll
.Text = ChrW(8221)
.Replacement.Text = " "
.Execute Replace:=wdReplaceAll
.Text = "'"
.Replacement.Text = ":"
.Execute Replace:=wdReplaceAll
.Text = ","
.Replacement.Text = " "
.Execute Replace:=wdReplaceAll
.Text = "(DP )([!^13]{1,})([^13]V D*V X[!^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**^pDP "
.Execute Replace:=wdReplaceAll

End With

End Sub
It works great on this exemple:
Quote:
TMA LYON partie 01.1 ”Tour du Pin”
45º37’25”N,005º23’53”E -- 45º33’11”N,005º25’11”E --
arc horaire de 18NM de rayon centré sur
45º44’44”N,005º05’26”E (VOR/DME LSE) --
45º31’52”N,005º23’26”E -- 45º34’00”N,005º21’00”E --
45º37’25”N,005º23’53”E
C
4500ft AMSL
------------
2500ft AMSL
But not on this one:

Quote:
LF P 4 LACQ
43º25’15”N,000º40’35”W -- 43º25’45”N,000º39’20”W --
43º23’22”N,000º33’45”W -- arc horaire de 5km de rayon
centré sur 43º23’53”N,000º37’22”W --
43º25’15”N,000º40’35”W
4100ft AMSL
------------
SFC
And I can't see the difference between these two examples
When I Copy/Paste from PDF file, I use "Paste without formating"
Could you illuminate the situation for me?

Thank you

Marc.
Reply With Quote
  #25  
Old 03-13-2013, 02:03 PM
macropod's Avatar
macropod macropod is offline Text manipulation in MACRO Windows 7 64bit Text manipulation in MACRO Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,384
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

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]
Reply With Quote
  #26  
Old 03-13-2013, 03:25 PM
srt srt is offline Text manipulation in MACRO Windows 8 Text manipulation in MACRO Office 2010 64bit
Novice
Text manipulation in MACRO
 
Join Date: Mar 2013
Location: Glasgow, UK
Posts: 15
srt is on a distinguished road
Default

ouch....
I'm so clueless...
tx
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text manipulation in MACRO 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
Text manipulation in MACRO Need help on Macro 03- Find text - if text is blank then remove line simpleonline1234 Word VBA 1 02-25-2011 02:28 AM
Text manipulation in MACRO 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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:48 PM.


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