FollowHyperlink causes error

M

Michelle

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
 
P

Peter T

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top