I am trying to place a hyperlink in a dynamic cell in another workbook. When I step into the line it gives me aN "Application-Defined or Object-Defined Error" and shuts down the macro, but it does actually do what I ask it do. The hyperlink is placed in the correct cell and with the correct text, But the macro still bugs so I can't move forward through the macro.
Please help.
I started this on another thread a few days ago, but the title no longer applies and I need to get the answer resolved quickly so I wanted to start a new thread.
http://www.mrexcel.com/forum/excel-...t-invoked-has-disconnected-clients-error.html
Code:
Private Sub CopyDataToMatrix()
'This macro copies the data from the process sheet & automatically pastes it into
'the matrix.
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim Data(1 To 26)
Dim EmptyRow As Range
Dim rowNum As Integer
Set wb1 = ActiveWorkbook
Set wb2 = Workbooks.Open("***ForPrivacy***")
Set ws1 = wb1.Sheets("ProcessData")
Set ws2 = wb2.Sheets("2016")
'Put all of the data into an array:
Data(1) = ws1.Range("B57").Value
Data(2) = ws1.Range("B3").Value
Data(3) = ws1.Range("B4").Value
Data(4) = ws1.Range("B5").Value
Data(5) = ws1.Range("F7").Value
Data(6) = ws1.Range("B6").Value
Data(7) = ws1.Range("B7").Value
Data(8) = ws1.Range("F8").Value
Data(9) = ws1.Range("B8").Value
Data(10) = ws1.Range("B9").Value
Data(11) = ws1.Range("B10").Value
Data(12) = ws1.Range("F9").Value
Data(13) = ws1.Range("F4").Value
Data(14) = ws1.Range("F5").Value
Data(15) = ws1.Range("F6").Value
Data(16) = ws1.Range("G4").Value
Data(17) = ws1.Range("G5").Value
Data(18) = ws1.Range("G6").Value
Data(19) = ws1.Range("H4").Value
Data(20) = ws1.Range("H5").Value
Data(21) = ws1.Range("H6").Value
Data(22) = ws1.Range("I4").Value
Data(23) = ws1.Range("I5").Value
Data(24) = ws1.Range("I5").Value
Data(25) = Left(wb1.Name, 8)
'Place the data into the IM Matrix file:
With ws2
Set EmptyRow = .Cells(.Rows.Count, 1).End(xlUp).Offset(1)
For i = LBound(Data) To 24
EmptyRow.Offset(0, i - 1).Value = Application.Index(Data, i)
Next i
For i = 25 To 25
[B] '''THE NEXT LINE IS WHERE THE ERROR HAPPENS:
EmptyRow.Offset(0, i - 1).Value = ws2.Hyperlinks.Add(EmptyRow.Offset(0, i - 1), wb1.FullName, , "Click to go to IML file.", Data(i))[/B]
Next i
End With
End If
'Close & save IM Matrix file:
wb2.Close SaveChanges:=True
End Sub
Please help.
I started this on another thread a few days ago, but the title no longer applies and I need to get the answer resolved quickly so I wanted to start a new thread.
http://www.mrexcel.com/forum/excel-...t-invoked-has-disconnected-clients-error.html
Last edited: