![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Microsoft Office support MS Office support forum |
![]() |
|
|
Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Jul 2008
Posts: 2
OS: XP
|
How to create a macro that will "Enter" after each semicolon in a MS Word Doc?
Hey everyone! First post, but I am a long time lurker of the forums here. EXCELLENT information!!
I have a 400 page MS Word document filled with email addresses separated by a semicolon. I place the mouse cursor after each semicolon, press enter, and the email address hyperlinks as rest of the email addresses move down. I'm tryiing to get a single column of hyperlinked email addresses that i can copy into excel for future use. It looks like this: emailaddress;emailaddress;emailaddress;emailaddress;emailaddress;emailaddress;emailaddress;emailaddress;emailaddress;emailaddress;emailaddress;emailaddress; When I manually do what I have described above it looks like this: emailaddress; emailaddress; emailaddress; emailaddress; Any ideas for a macro that can locate every semicolon and press the "enter" key form me while hyperlinking? Thanks guys,Josh |
|
|
|
|
|
#2 (permalink) |
|
Registered User
Join Date: May 2008
Location: Baltimore, Maryland
Posts: 97
OS: Windows XP SP3
|
Re: How to create a macro that will "Enter" after each semicolon in a MS Word Doc?
You may find this code useful, even if it isn't very pretty. It was thrown together rather quickly and probably could use some more tweaking and testing.
Code:
Sub sep()
Dim dfind As Boolean
Do
ActiveDocument.Content.Select
dfind = False
Selection.Find.Execute FindText:=";", Forward:=True
If Selection.Find.Found = True Then
dfind = True
Selection.TypeParagraph
Selection.MoveUp wdLine, 1
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _
Address:="mailto:" & Selection.Text, _
TextToDisplay:=Selection.Text
End If
Loop While dfind = True
End Sub
Last edited by David M58 : 07-17-2008 at 03:49 PM. |
|
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: Jul 2008
Posts: 2
OS: XP
|
Re: How to create a macro that will "Enter" after each semicolon in a MS Word Doc?
David M58,
Thank you for your quick reply! The macro you provided is excellent!! Seems to work just fine for me. Brilliant!! But, if I could have just one more birthday present this year I would ask you to either: A)Edit your macro to insert a semicolon at the end of each email address (the semicolon at the end of each is not included in the hyperlink and serves to seperate the email address "automatically" when multiple address are copied and pasted into the outlook recipient field.) or, B)Design a new macro code that will insert the semicolons ad described above I really suck at macros, and trying to accomplish this substantial task of sorting these email address doesn't allow any free time to experiment with the macros as I'd like. You can see in the lead post the example of the semicolon at the end of each address. But in the word document the semicolon is not part of the hyperlink though it is placed directly after the address. Thank you again David. your knowledge is invaluable! -Josh |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: May 2008
Location: Baltimore, Maryland
Posts: 97
OS: Windows XP SP3
|
Re: How to create a macro that will "Enter" after each semicolon in a MS Word Doc?
How about this:
After running the macro, do a find and replace. Find what: ^p Replace with: ;^p |
|
|
|
![]() |
| Thread Tools | |
|
|