1

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)

2
  • 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... Apr 9, 2013 at 5:31
  • 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
    Apr 9, 2013 at 5:44

1 Answer 1

1

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
1
  • I decided to open a new workbook in the else section but I am not really satisfied with that solution. Is there a way to open webpage that does not require a workbook object? Do you know why it requires workbook object at all?
    – Mr1159pm
    Apr 10, 2013 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.