1
votes

I created a custom UI in excel 2007 as a part of xlam add-in. The custom tab includes a button that opens a website when clicked.

I used ThisWorkbook.followHyperlink "address"

The add-in is password protected which causes excel to crash whenever i click on the button while in xlam add-in. Everything works fine when I use it in an .xlsm file.

I think the problem is in the ThisWorkbook being password protected. I could use ActiveWorkbook instead but the app would crash when there is no workbook open.

Any suggestions how I could work around this? (Unprotecting the file is not an option)

1
Do you have any error handling code around?? That would help if you switch from ThisWorkbook into ActiveWorkbook according to what you said. You could show part of your code to get additional information...Kazimierz Jawor
That's all the code there is in the UI call back function. It is just meant to go to a website when button is clicked. Excel just crashes I don't have any error code or anything.Mr1159pm

1 Answers

1
votes

Including information from comment + assumption that this need to work only when any activeworkbook is open... than you could try to change from Thisworkbook into Activeworkbook in the way like this:

Sub FollowingHyperlink()

   'check if there is anything open
If Not ActiveWorkbook Is Nothing Then
    ActiveWorkbook.FollowHyperlink "http://www.stackoverflow.com"
Else
    'if not... it depends what you have and what you need
    'you could just open any new workbook
    '**This part of code edited**
    'or use this technique to navigate to page using IE:
    Dim ieAPP
    Set ieAPP = CreateObject("InternetExplorer.application")
    ieAPP.Visible = True
    ieAPP.navigate "http://www.stackoverflow.com"
End If

End Sub