Results 1 to 2 of 2

Thread: Need help with syntax with a quick Macro

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    1

    Need help with syntax with a quick Macro

    I have a 154 page document that requires me to edit each line to a specific format. I need to change lines like this:

    scielo.isciii.es/scielo.php/script_sci_serial/pid_1139-1375/lng_en/nrm_iso
    www.scielo.br/ag
    www.zoosystema.com
    http://www.scielo.br/scielo.php/scri...lng_en/nrm_iso
    www.ijnephrol.com/index2.htm
    jcom.sissa.it/


    to this:

    scielo.isciii.es
    www.scielo.br
    www.zoosystema.com
    www.scielo.br
    www.ijnephrol.com
    jcom.sissa.it


    Now the research I've done so far has led me to this (please forgive me I'm a java programmer and without a reference book I'm lost):

    VB Code:
    1. For Each element In collection
    2. '    determine the column the first / occurs and save into a variable
    3. '    delete all characters from variable to end of the line
    4. Next element

    now I know a few things:

    -I need element to be each line/paragraph of the document. I say line because each URL encompasses one line. But I also say paragraph because there is a carriage return at the end of each line.
    -I know collection should be the full document but I'm not sure how.
    -I have no idea how to determine what column a specific character occurs
    -I have no idea how to delete characters

    That said I've tried MSDN and that is the worst means to find information I've ever seen. Hate it.

    Any help would be greatly appreciated.
    Last edited by rkidd; May 2nd, 2006 at 02:52 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need help with syntax with a quick Macro

    Welcome to the Forums.

    Sounds like your using a Word document?

    If so there is a Hyperlinks collection that you would use in the format you posted.


    VB Code:
    1. Dim hyp As Word.Hyperlink
    2.  
    3. For Each hyp In ActiveDocument.Hyperlinks
    4.     MsgBox hyp.Address
    5. Next
    Now you can write the hyperlink url out to a file or whatever instead of the example MsgBox. You can change the link or the display text or ? you need to do.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width