September 21, 2012

Hyperlink Word Document to Excel

Following code will links to the word file as link  in excel cell you able to type the filename.doc in the cell and it links to that file in a directory

 Private Sub HyperLinkToWordDoc()  
 Dim oCell As Range  
 Dim iRow As Integer  
 Dim iCount As Integer  
 iRow = Cells.SpecialCells(xlLastCell).Row  
 For iCount = 2 To iRow  
 oCell = Cells(iCount, 5)  
 If oCell.Text <> "Link" And Len(oCell.Text) > 0 Then  
 oCell.Hyperlinks.Add(oCell, oCell.Text, , , "Link")  
 End If  
 Next iCount  
 End Sub