Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2014, 01:34 PM
gmaxey gmaxey is offline RichTextContentControl with text and hyperlinks via Userform possible? Windows 7 32bit RichTextContentControl with text and hyperlinks via Userform possible? Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Michael,

Again, hard to offer much without your form. However look at your code that works for inserting a stand alone hyperlink. Notice the first parameter you define is the "anchor" as "Selection.Range." Now look at your main code:

.Cell(webIndex + 1, 3).Range.End -1 = ActiveDocument.Hyperlinks.Add(oObjForm.webaddTextB ox.Text, _
"", "", TextToDisplay:=oObjForm.dspTextBox.Text)

That is a real dog's breakfast ;-). oObjForm.webaddTextBox.Text is "address text" it is not an anchor.

First you need to get your anchor. Ok, it is clear that you want the anchor to be at the end of a defined cell. Take a look at this and see if it doesn't help you sort it out.



Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oTbl As Word.Table
Dim lngIndex As Long
Dim oRngAnchor As Range
  Set oTbl = ActiveDocument.Tables(1)
  For lngIndex = 1 To oTbl.Rows.Count
    Set oRngAnchor = oTbl.Cell(lngIndex, 1).Range
    oRngAnchor.Collapse wdCollapseEnd
    oRngAnchor.End = oRngAnchor.End - 1
    oRngAnchor.InsertBefore " "
    oRngAnchor.Collapse wdCollapseEnd
    ActiveDocument.Hyperlinks.Add oRngAnchor, "http//www.google.com", , "Lets brows Google", "Browse Google"
  Next lngIndex
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #2  
Old 09-24-2014, 12:38 PM
odin odin is offline RichTextContentControl with text and hyperlinks via Userform possible? Windows 7 64bit RichTextContentControl with text and hyperlinks via Userform possible? Office 2010 64bit
Novice
RichTextContentControl with text and hyperlinks via Userform possible?
 
Join Date: Sep 2014
Posts: 11
odin is on a distinguished road
Default

Greg,

THANK YOU!! I was able to get it to work. It works just the way I needed. I only need one more piece to my puzzle figured out and all should be well.

As can be seen from my full code that I posted earlier, I'm using a Collection for the hyperlink data. Is there a way to check how many entries are in a Collection? If so, how would I go about getting that information?

What I'm needing is to be able to add "&" in between the hyperlinks when there is more than one hyperlink. I know I can use an If statement to determine if the collection has more than 1 entry, to do one process and if not then do another process. But other than that I'm not sure what the best approach would be to accomplish this. Would it be if there's more than one entry to just put the "&" after all of the links and then have the code delete the last "&". Or to get an accurate count some how and only place "&" between the links.

Thank you,
Michael
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy userform text and formfield contents to outlook? odin Word VBA 7 09-09-2014 11:56 AM
RichTextContentControl with text and hyperlinks via Userform possible? Is it possible to take an input from a UserForm in one document to a UserForm in a do BoringDavid Word VBA 5 05-09-2014 09:08 AM
cross reference hyperlinks to text box nothing_kills Word 4 11-25-2013 09:21 AM
RichTextContentControl with text and hyperlinks via Userform possible? Inserting Text and Hyperlinks DrDOS Excel 2 03-21-2012 03:53 AM
RichTextContentControl with text and hyperlinks via Userform possible? Checkbox on Userform result in Text in Word Dolfie_twee Word VBA 1 06-22-2010 07:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:44 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft