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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > Microsoft Support > Microsoft Office support
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read

Microsoft Office support MS Office support forum

Reply
 
Thread Tools
Old 07-17-2008, 10:39 AM   #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
kingjoshdude81 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 07-17-2008, 03:48 PM   #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
If the Word document contains only e-mail addresses separated by semicolons, and nothing else, and if this code works right, it should place each e-mail address on its own separate line. Modify as necessary.

Last edited by David M58 : 07-17-2008 at 03:49 PM.
David M58 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 07-22-2008, 01:28 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
kingjoshdude81 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 07-22-2008, 02:55 PM   #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
David M58 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -7. The time now is 06:39 PM.



Copyright 2001 - 2008, Tech Support Forum

Search Engine Friendly URLs by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82