View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default FollowHyperlink causes error

it stops on this line
Set xRange = Range(rngRange)
where rngRange is a RefEdit control with a valid range reference in it


The Refedit contol defaults to its value property, range address including
sheet name. If the workbook is no longer active you will have a problem to
reference the range.

Try something like this (in the userform)

Private m_rngRF As Range

Private Sub RefEdit1_Change()
Set m_rngRF = Range(RefEdit1.Value)
End Sub


then when you want your range simply refer to the range object m_rngRF (of
course you will also need to have checked it exists, ie user has selected a
range)

Regards,
Peter T

"Michelle" wrote in message
...
I have some code that works fine, unless I have followed a hyperlink first.

I have built a form which all works correctly, and I have now added an
image which triggers a hyperlink in its click-event.
(ActiveWorkbook.FollowHyperlink Address:="http://www.myAddressHere.co.uk",
NewWindow:=True)

If I use the hyperlink, and then go back and try and continue using the
form, then nothing works, I get an error:
Method 'Range' of object '_Global' failed

it stops on this line
Set xRange = Range(rngRange)
where rngRange is a RefEdit control with a valid range reference in it -
it works fine if I haven't clicked the hyperlink first.

I could lose the hyperlink, but I'd really like to get to the bottom of
this. Any ideas?

Thanks

Michelle