View Single Post
 
Old 07-18-2016, 04:38 AM
jroger05 jroger05 is offline Windows XP Office 2003
Novice
 
Join Date: Aug 2010
Posts: 6
jroger05 is on a distinguished road
Default Not sure how to integrate code into mine.

Doug,

To describe this a little better. I have a table with 4 columns.
0x0
R
Red_Version_ID_Reg
FPGA Version ID register
0x2
RW
Red_InfoSec_Status_Reg
SP to OMAP infosec status register


I am traversing the table through the VBA and then adding the hyperlink to the the third column. Obviously my way is unfortunately causing the hyperlink to another document. I am not sure how to integrate your solution into my code. I am sure my code is more complicated than it needs to be, but being a novice it is what I could figure out.

Thanks.






Sub Create_Memory_Map_HyperLinks()
Dim J As Integer
Dim iTableNum As Integer
Dim oTbl As Table
Dim oRow As Row

'Define variables for the processing of cells
Dim oCell As Cell
Dim sCellText As String

'Define variables for the processing of the cells
Dim rw_oCell As Cell
Dim rw_sCellText As String

' Define variable for the Reg Name cell
Dim oRng As Range
' Define variable for the RW cell
Dim RW_oRng As Range
' Define a loop variable to be used for the row being processed
Dim tbl_loop_variable As Integer

' If user is currently not in a table then go to the next table
If Selection.Information(wdWithInTable) = False Then
Selection.GoToNext What:=wdGoToTable
End If
Selection.Bookmarks.Add ("TempBM")
For J = 1 To ActiveDocument.Tables.Count
Set oTbl = ActiveDocument.Tables(J)
oTbl.Select
If Selection.Bookmarks.Exists("TempBM") Then
iTableNum = J
Exit For
End If
Next J
ActiveDocument.Bookmarks("TempBM").Select
ActiveDocument.Bookmarks("TempBM").Delete
' MsgBox "The current table is table " & iTableNum


' Set the current table to be the active table
' ActiveDocument.Tables(iTableNum).Select


NumRows = Selection.Tables(1).Rows.Count
NumCols = Selection.Tables(1).Columns.Count
' MsgBox "The current table has " & NumRows & " Rows"
' MsgBox "The current table has " & NumCols & " Columns"
' now cycle through the rows of the selected table.
tbl_loop_variable = 0

For Each oRow In Selection.Tables(1).Rows
' Need to skip the first two rows of the table
' Select the cell in column 3
tbl_loop_variable = tbl_loop_variable + 1
If tbl_loop_variable > 2 Then
' Handle the Reg Name
Set oRng = oRow.Cells(3).Range
Set oCell = oRow.Cells(3)
sCellText = oCell.Range
' Remove table cell markers from the text.
sCellText = Left$(sCellText, Len(sCellText) - 2)

' Handle the R/W Cell
Set RW_oRng = oRow.Cells(2).Range
Set rw_oCell = oRow.Cells(2)
rw_sCellText = rw_oCell.Range
' Remove table cell markers from the text.
rw_sCellText = Left$(rw_sCellText, Len(rw_sCellText) - 2)
' MsgBox rw_sCellText
' Check the RW Cell to ensure that it is not blank (ie second line of range)
If (rw_sCellText = "R") Or (rw_sCellText = "R/W") Or (rw_sCellText = "W") Or (rw_sCellText = "RW") Then
' MsgBox "In the R/W section"
If sCellText = "Reserved" Then
' MsgBox "Found the Reserved"
Else
If sCellText = " " Then
' MsgBox "Found the Empty Cells"
Else
' MsgBox sCellText
' link2create = "C3_" & oRng
link2create = oRng
ActiveDocument.Hyperlinks.Add Anchor:=oRng, _
Address:="", _
SubAddress:=link2create, ScreenTip:="", _
TextToDisplay:=txt2cpy

End If
End If
End If
End If
Next oRow
End Sub
Reply With Quote