![]() |
|
|
|
#1
|
|||
|
|||
|
It is difficult to help you without seeing the full code. For example, you posted:
Code:
Sub insertLink()
Dim dspTxt As String
Dim webTxt As String
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"http://www.microsoft.com", SubAddress:="", ScreenTip:="", TextToDisplay:="Testing Link"
Code:
.Cell(webIndex + 1, 3).Range.End -1 = ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:=oObjForm.webaddTextBox.Text, _
SubAddress:="", ScreenTip:="", TextToDisplay:=oObjForm.dspTextBox.Text
What is your full code? |
|
#2
|
|||
|
|||
|
Greg,
I'm sorry the code was incomplete and cryptic. I want to thank you for your website, it's been a lot of help and a LOT of information. The main code I'm trying to get to work is 95% from your site. I'm still testing the whole code, so there may be other errors. The code that works without any issue for inserting a hyperlink is: Code:
Sub insertLink() Dim dspTxt As String Dim webTxt As String dspTxt = "testing Link" webTxt = "http://www.microsoft.com" 'Write the hyperlink ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _ webTxt, SubAddress:="", ScreenTip:="", TextToDisplay:= _ dspTxt End Sub Here is the whole code below that I'm trying to work out: Code:
Option Explicit
Public oCol As Collection
Sub AddMaterialCollection()
Dim oFrmInput As fmAddMaterial, oObjForm As Object
Dim bRepeat As Boolean
Dim oCol As Collection
Dim oTbl As Table
Dim lngIndex As Long
Dim webIndex As Long
'Initialize the collection.
Set oCol = New Collection
'Set up loop to collect repeating section information from document user.
bRepeat = True
Do While bRepeat
Set oFrmInput = New fmAddMaterial
With oFrmInput
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
.Show
End With
If oFrmInput.Tag <> "USER CANCEL" Then
'Add the userform objects to the collection.
oCol.Add oFrmInput
Else
Exit Do
End If
bRepeat = oFrmInput.Tag
Loop
'Targets document table and output information.
Set oTbl = ActiveDocument.Tables(1)
With oTbl
'Add data to table.
'On Error GoTo Err_NoRecords
For lngIndex = 1 To oCol.Count
Set oObjForm = oCol.Item(lngIndex)
.Cell(lngIndex + 1, 1).Range.Text = oObjForm.qtyBox.Text
.Cell(lngIndex + 1, 2).Range.Text = oObjForm.markBox.Text
.Cell(lngIndex + 1, 3).Range.Text = oObjForm.descBox.Text & " " & "FABRICATE AS SHOWN: "
Set oObjForm = Nothing
'Next lngIndex
'End With
With oTbl
'Add Links to end of table.
On Error GoTo Err_NoRecords
For webIndex = 0 To oCol.Count
Set oObjForm = oCol.Item(webIndex)
.Cell(webIndex + 1, 3).Range.End -1 = ActiveDocument.Hyperlinks.Add(oObjForm.webaddTextBox.Text, _
"", "", TextToDisplay:=oObjForm.dspTextBox.Text)
Set oObjForm = Nothing
Next webIndex
'End With
'Write the hyperlink
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
oObjForm.webaddTextBox.Text, SubAddress:="", ScreenTip:="", TextToDisplay:= _
oObjForm.dspTextBox.Text
'Report
MsgBox "Data you entered has been tranfered to the table." & vbCr + vbCr _
& "You can edit, add or delete information to the defined table as required", _
vbInformation + vbOKOnly, "DATA TRANSFER COMPLETE"
CleanUp:
Set oTbl = Nothing
Set oCol = Nothing
Unload oFrmInput
Set oFrmInput = Nothing
Exit Sub
Err_NoRecords:
MsgBox "You didn't provide any Links." & vbCr + vbCr _
& "You can edit and add information to the basic table if required", _
vbInformation + vbOKOnly, "NO DATA PROVIDED"
Resume CleanUp
End Sub
I hope you can help me figure this thing out. Thank you, Michael |
|
|
|
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 |
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 |
Inserting Text and Hyperlinks
|
DrDOS | Excel | 2 | 03-21-2012 03:53 AM |
Checkbox on Userform result in Text in Word
|
Dolfie_twee | Word VBA | 1 | 06-22-2010 07:54 AM |