ben.oates
04-01-2008, 05:44 AM
Hi all,
Another day of confusion for me. Take a look at this:
Public Sub testIt()
Dim docURI As String
docURI = "myURI"
Dim wf As New WorkFunctions
Dim hl As New Hyperlink
Set hl = wf.URIClean(docURI)
MsgBox hl.Address & " " & hl.ScreenTip & " " & hl.TextToDisplay
End Sub
WorkFunctions is my Class Module. URIClean is definitely a public Function in that module that returns Type Hyperlink (shown below). For some reason, when I try and call the function I get an Error 91: Object variable or With block variable not set on the "hl = wf..." etc.
I have tried it with/without Set and New statements on that line and the 2 above and I still get the same error on the same line.
Any ideas, please? Online help tells me to do what I have already tried. What am I missing?
Public Function URIClean(cleanMe As String) As Hyperlink
cleanMe = Replace(cleanMe, "%2F", "/")
cleanMe = Replace(cleanMe, "%2D", "-")
cleanMe = Replace(cleanMe, "%2E", ".")
cleanMe = Replace(cleanMe, "%5F", "_")
URIClean.Address = cleanMe
cleanMe = Replace(cleanMe, "%20", " ")
URIClean.TextToDisplay = Right(cleanMe, InStrRev(cleanMe, "/"))
URIClean.ScreenTip = "Click here to access " & URIClean.TextToDisplay
End Function
Another day of confusion for me. Take a look at this:
Public Sub testIt()
Dim docURI As String
docURI = "myURI"
Dim wf As New WorkFunctions
Dim hl As New Hyperlink
Set hl = wf.URIClean(docURI)
MsgBox hl.Address & " " & hl.ScreenTip & " " & hl.TextToDisplay
End Sub
WorkFunctions is my Class Module. URIClean is definitely a public Function in that module that returns Type Hyperlink (shown below). For some reason, when I try and call the function I get an Error 91: Object variable or With block variable not set on the "hl = wf..." etc.
I have tried it with/without Set and New statements on that line and the 2 above and I still get the same error on the same line.
Any ideas, please? Online help tells me to do what I have already tried. What am I missing?
Public Function URIClean(cleanMe As String) As Hyperlink
cleanMe = Replace(cleanMe, "%2F", "/")
cleanMe = Replace(cleanMe, "%2D", "-")
cleanMe = Replace(cleanMe, "%2E", ".")
cleanMe = Replace(cleanMe, "%5F", "_")
URIClean.Address = cleanMe
cleanMe = Replace(cleanMe, "%20", " ")
URIClean.TextToDisplay = Right(cleanMe, InStrRev(cleanMe, "/"))
URIClean.ScreenTip = "Click here to access " & URIClean.TextToDisplay
End Function