Russ
Tue Jun 26 00:53:57 CDT 2007
Francis,
If Word has changed all your urls to hyperlinks you could change their font
to hidden. As a matter of fact, you could change the whole document font to
hidden (Activedocument.Range.Font.Hidden = True) and then expose the text
you want to act on by changing that to unhidden. Or Vice Versa, hide what
you don't want to interact with, if that way is faster. Some people do the
same thing by highlighting text temporarily. And search through the
unhighlighted text.
Anyway you can hide all the hyperlinks.
Dim aLink As Word.Hyperlink
For Each aLink In ActiveDocument.Hyperlinks
aLink.Range.Font.hidden = True
Next aLink
You could also narrow it down to just urls that are hyperlinks:
Dim aLink As Word.Hyperlink
For Each aLink In ActiveDocument.Hyperlinks
If InStr(aLink.Range.Text, "://") > 0 Then
aLink.Range.Font.hidden = True
End If
Next aLink
Then search for stops:
Dim aRange As Word.Range
Set aRange = ActiveDocument.Range
With aRange.Find
.Text = "."
.Font.hidden = False
.Replacement.Text = ". "
.Execute Replace:=wdReplaceAll
End With
And then when finished unhide those things hidden:
Dim aLink As Word.Hyperlink
For Each aLink In ActiveDocument.Hyperlinks
If InStr(aLink.Range.Text, "://") > 0 Then
aLink.Range.Font.hidden = False
End If
Next aLink
Or:
Activedocument.Range.Font.Hidden = False
> Russ, sorry - I'm not making myself clear as usual.
>
>
>
> The 'Tidy up' macro, intended to cope with typos, carries out a sequence of
> Replaces in order to eliminate multiple spaces and ensure there is a space
> AFTER a period (UK calls them full stops) and not BEFORE. Similarly there is
> control over spaces associated with commas and various other things like
> parentheses and exclamations.
>
>
>
> One problem is that numbers like 1,000.00 end up as 1, 000. 00 but that is
> corrected at the end of the macro by the code copied below.
>
>
>
> What I should like to achieve, at the beginning of the macro, is to find
> 'www.' at beginning of a URL, then replace the 'dots' with something
> unlikely to appear in the text as a whole (maybe 'xox').
>
> The carry out the 'Tidy up'.
>
> The, at the end of the macro, replace the 'xox's with dots.
>
>
>
> Searching for 'www.' would bring us to:
>
>
http://www.cambridgerotary.org.uk/kluby.php?id_klubu=3
>
>
>
> How can we select everything backwards to the first space (picking up
>
http:// if it is included) and forward to the first space in order to do a
> Replace of the dots with a temporary 'xox'?
>
>
>
> It is beyond me?
>
>
>
> Francis
>
>
>
> 'No space in #,##0.00
>
> With Selection.Find
>
> .ClearFormatting
>
> .Replacement.ClearFormatting
>
> .Text = "(.)([!0-9])"
>
> .MatchWildcards = True
>
> .Replacement.Text = "\1 \2"
>
> .Execute Replace:=wdReplaceAll
>
> End With
>
> With Selection.Find
>
> .ClearFormatting
>
> .Replacement.ClearFormatting
>
> .Text = "(,)([!0-9])"
>
> .MatchWildcards = True
>
> .Replacement.Text = "\1 \2"
>
> .Execute Replace:=wdReplaceAll
>
> End With
>
>
>
>
>
>
>
> "Russ" <drsN0SPAMmikle@hotmailD0Tcom.INVALID> wrote in message
> news:C2A46F94.1A3E2%drsN0SPAMmikle@hotmailD0Tcom.INVALID...
>> Inline reply
>>
>>> Thanks for the thought Russ - having found the URL at the beginning of
>>> the
>>> 'Tidy up' macro
>> Are you implying that the tidy up macro is already capabable of finding
>> urls? How?
>> Unless they are delimited by special characters or formatting, they will
>> be
>> hard to find.
>> Otherwise, as I said in my last post, how will you know where the url
>> ends?
>> At which space character?
>>
>> Your macro might make:
>> **Http://google .com This sentence is not part of url.**
>> Look like
>> **Http://google.comThissentenceisnotpartofurl.**
>>
>>> the 'dots' could be changed for something unlikely such as
>>> 'zxz' and then, after all the corrections in the body of the macro have
>>> been
>>> made, change the 'zxz' bac to 'dots'.
>>
>> Why are you concerned about the dots?
>>
>>> But how, having found the URL, can it
>>> be isolated in order to do a Replace and then go on to find any others?
>>
>> Replacement is the easier part.
>>>
>>> I think I could do it in XL but not in Word. Can you or anyone?
>>>
>>> Francis
>>>
>>> "Russ" <drsN0SPAMmikle@hotmailD0Tcom.INVALID> wrote in message
>>> news:C2A42B96.1A3CE%drsN0SPAMmikle@hotmailD0Tcom.INVALID...
>>>> Searching for :// might get you there to visually check the url. But how
>>>> is
>>>> code going to know that a trailing space is or is not there to terminate
>>>> the
>>>> url address?
>>>>
>>>>> Checking text before inclusion in my club bulletin, I use a 'Tidy up'
>>>>> macro
>>>>> to get rid of white space, make sure there is a space after a period
>>>>> and
>>>>> comma and not before, etc, etc. With MVP help it also makes sure there
>>>>> is
>>>>> not a space after a full stop and comma in a figure, as in £1,000.00
>>>>>
>>>>>
>>>>>
>>>>> The only remaining problem is to make sure there are not spaces in
>>>>> URLs.
>>>>>
>>>>>
>>>>>
>>>>> Any suggestions?
>>>>>
>>>>>
>>>>>
>>>>> Francis Hookham
>>>>>
>>>>>
>>>>
>>>> --
>>>> Russ
>>>>
>>>> drsmN0SPAMikleAThotmailD0Tcom.INVALID
>>>>
>>>
>>>
>>
>> --
>> Russ
>>
>> drsmN0SPAMikleAThotmailD0Tcom.INVALID
>>
>
>
--
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID