When I run the macro from my pc (windows XP, Office 2007) I dont get any error but when Its run from a Windows 7 machine on Office 2010, I get run time error 91, Object Variable or With Block Variable not set.
Im not sure why this is because the variable is set... but here is the macro.
Sub OpenHyperlink()
Dim IE As Object
Dim r As String
Dim msg As String
If Range("A" & ActiveCell.Row).Hyperlinks.Count > 0 Then
r = Range("A" & ActiveCell.Row).Hyperlinks(1).Address
If Right(r, 6) = "%22%22" Then
r = Left(r, Len(r) - 3)
End If
Else
r = MsgBox("There is no record of this incident in Remedy.")
Exit Sub
End If
With CreateObject("Shell.Application").Windows
If .Count > 0 Then
Set IE = .Item(0) ' or .Item(.Count - 1)
Else
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
End If
End With
IE.Navigate (r), CLng(&H800)
End Sub
I did notice an issue with the last section... but I copied that part from another website so I am not really sure what it does or how to fix it.
With CreateObject("Shell.Application").Windows
If .Count > 0 Then
Set IE = .Item(0) ' or .Item(.Count - 1)
Else
the Set IE = .Item(0)
feels wrong, but im not sure what it does. It should detect if an internet explorer is open (I think) but im not sure what I should replace it with in order to open it.
im not sure anyway, just a guess. If that isnt the issue, im not sure what is.
Bookmarks