View Single Post
 
Old 09-18-2014, 01:34 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
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