Hello

I have a several hundres pages with content in the following format:
<text as hyperlink><1 empty space><any text any size>

I want to have it converted to somehting like the following:
<Text from oringal hyperlink astext>
<hyperlink as URL from original hyperlink>
<any text any size>

Can someone please help on this?

Thanks for any feedback,
Frank

Re: Hyerlink Modification help needed by Dave

Dave
Thu Aug 03 15:00:28 CDT 2006

Hi Frank,
This seems to do the trick on my machine.

Dim lLink As Long
Dim oLink As Hyperlink
Dim oRng As Range
For lLink = ActiveDocument.Hyperlinks.Count To 1 Step -1
Set oLink = ActiveDocument.Hyperlinks(lLink)
Set oRng = oLink.Range
oRng.End = oRng.End + 1
oRng.Characters.Last.Delete
oRng.InsertAfter vbCrLf
oRng.InsertBefore Text:=oLink.TextToDisplay & vbCrLf
oLink.TextToDisplay = oLink.Address
Next lLink


HTH,
Dave

"Frank" <Frank@discussions.microsoft.com> wrote in message
news:2EB893FD-10FA-47CA-8667-9C2984DB76F4@microsoft.com...
> Hello
>
> I have a several hundres pages with content in the following format:
> <text as hyperlink><1 empty space><any text any size>
>
> I want to have it converted to somehting like the following:
> <Text from oringal hyperlink astext>
> <hyperlink as URL from original hyperlink>
> <any text any size>
>
> Can someone please help on this?
>
> Thanks for any feedback,
> Frank
>



Re: Hyerlink Modification help needed by Frank

Frank
Thu Aug 03 15:12:01 CDT 2006


Awesome!
So many thanks!!!

One thing: Is it possible to strip any applid style to this "range of text"
AND set the "headline" to the Headline 2 style?

Sameple:
<Text from oringal hyperlink as Heading 2>
<hyperlink as URL as URL style>
<some text based on normal style>

Can that be done as well?
Where can I read more on how to make my own makros and fancy stuff like this
here?


Re: Hyerlink Modification help needed by Dave

Dave
Fri Aug 04 08:19:31 CDT 2006

Hi Frank,

Yes, it is possible. Here's what works on my machine:

Dim lLink As Long
Dim oLink As Hyperlink
Dim oRng As Range
Dim oRngPara As Range
Dim lPara As Long
For lLink = ActiveDocument.Hyperlinks.Count To 1 Step -1
Set oLink = ActiveDocument.Hyperlinks(lLink)
Set oRng = oLink.Range
oRng.End = oRng.End + 1
oRng.Characters.Last.Delete
oRng.InsertAfter vbCrLf
oRng.InsertBefore Text:=oLink.TextToDisplay & vbCrLf
oLink.TextToDisplay = oLink.Address
'''format the paragraphs before and after
'''1. set a range from beginning of doc
'''to end of hyperlink para
Set oRngPara = ActiveDocument.Range _
(Start:=ActiveDocument.Range.Start, _
End:=oRng.End)
'''count the # of paras in that range
lPara = oRngPara.Paragraphs.Count
'''format the para before hyperlink para
ActiveDocument.Paragraphs(lPara - 1).Range.Style = "Headline 2"
'''format the para after hyperlink para
ActiveDocument.Paragraphs(lPara + 1).Range.Style = "Normal"
Next lLink

You can learn a lot about macros by recording them (this is best when you
don't know what object, property, or method you need to access). I learned
this way and found it effective initially, especially considering that Word
has the largest object model of the office applications. Once I moved beyond
recording macros, I liked the book Word Programming; it's a little technical
(what should I have expected?), but it helped me understand the object
model. After that, I most often refer to the Word MVP site at
http://word.mvps.org/FAQs/General/index.htm

From there, you can find other Web sites that are very useful (I don't use
them very often, but a beginner/learner could get some excellent information
from them). Click the About Us link in the top navigation bar. If you then
"read up" on the MVPs, you will notice that many of them have their own Web
sites. Go to those Web sites and browse around. You will pick up a lot of
information.

Finally, lurk. Read posts that interest you from the usual suspects (those
who answer a lot of the questions); there excellent information. For
example, I learned that we need to enumerate through the hyperlinks
collection by starting with the last one if you intend to remove the
hyperlink from the text. That is, you can't enumerate through ALL of Word's
collections in some circumstances, but going through them in reverse order
(starting with the last) is probably the safest bet for all collections.

HTH,
Dave

"Frank" <Frank@discussions.microsoft.com> wrote in message
news:2D805516-AD0B-418F-B115-7A3BDF4B4A9F@microsoft.com...
>
> Awesome!
> So many thanks!!!
>
> One thing: Is it possible to strip any applid style to this "range of
> text"
> AND set the "headline" to the Headline 2 style?
>
> Sameple:
> <Text from oringal hyperlink as Heading 2>
> <hyperlink as URL as URL style>
> <some text based on normal style>
>
> Can that be done as well?
> Where can I read more on how to make my own makros and fancy stuff like
> this
> here?
>