View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Preventing compile errors when referencing objects ehanced after 1997

Sub Tester3()
#If VBA6 Then
ActiveSheet.Hyperlinks.Add Anchor:=Selection, _
Address:="", SubAddress:="", ScreenTip:="This is it, yea"

#Else

ActiveSheet.Hyperlinks.Add Anchor:=Selection, _
Address:="", SubAddress:=""

#End If
End Sub

This specific code Untested in xl97, but should work.
--
Regards,
Tom Ogilvy

"Matt Somers" wrote in message
m...
Hey Guys and Gals:

I am using the Hyperlink object for an Excel application intended for
use on Excel 97 and Excel 2000. I developed the code in 2000 with
syntax like:

ActiveSheet.Hyperlinks.Add Anchor:=Selection Address:="",
SubAddress:="", ScreenTip:="This is it, yea"

..but oops, darn it.

In 1997, ScreenTip was not around..so I'm talking space shuttles when
the program's talking Kitty Hawk..so I tried (code below) and got a
"compile error"

if left(Application.version,1) <= 8 then

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:=""

else

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:="", ScreenTip:="This is it, yea"

end if

Compile error makes sense in retrospect. (but its always rush, rush,
rush and not much thinky, thinky, thinky)

Matt