ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FollowHyperlink causes error (https://www.excelbanter.com/excel-programming/420167-followhyperlink-causes-error.html)

Michelle

FollowHyperlink causes error
 
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


Peter T

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





All times are GMT +1. The time now is 08:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com