Results 1 to 5 of 5

Thread: Create dynamic hyperlink

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2004
    Posts
    59

    Create dynamic hyperlink

    hi

    i have a word document which is connected to a database via vba. i am able to extract text from the database and display in on the page.

    how do i insert this text from the database into word as a hyperlink?

    thanks

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

    Re: Create dynamic hyperlink

    You can change this to use variables.
    VB Code:
    1. ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="http://www.vbforums.com", SubAddress:="", ScreenTip:="", TextToDisplay:="vbforums"
    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

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2004
    Posts
    59

    Re: Create dynamic hyperlink

    Excellent

    I will be trying that out in a bit. Will let you know if it works!

    Thanks

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 2004
    Posts
    59

    Re: Create dynamic hyperlink

    no i can't get it to work. basically i want the hyperlink to be added to a certain bookmark. the following code i have and it gives an error

    ActiveDocument.Hyperlinks.Add Anchor:=SetBookmark "bmEmail", Address:="Mailto:" & strEmail, SubAddress:="", ScreenTip:="", TextToDisplay:="Email"

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2004
    Posts
    59

    Re: Create dynamic hyperlink

    Ok i now have this code which adds the dynamic hyperlink NEXT to the bookmark. How to I insert it INTO the bookmark?

    VB Code:
    1. ActiveDocument.Bookmarks("bkEmail").Select
    2.     ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="mailto:" & strEmail, TextToDisplay:=strEmail

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