How to create a hyperlinked menuitem

metropol
04-24-2008, 12:20 AM
I'm creating a menu with menuitems.

Is there an easy way to add a hyperlink to a menu instead of a macro?


With mybutton.customMenu.controls.add(type:=msocontrolbutton)
.caption = "Userdocumentation"
.faceid = 277
.onaction = "macro1"
end with

I want to replace the ".onaction" with a hyperlink to a user document insted.

Thanks.

tinyjack
04-24-2008, 06:17 AM
Not sure, but you could always just get macro1 to open the document.

TJ

Mill
04-25-2008, 06:33 AM
Not sure, but you could always just get macro1 to open the document.

TJ

Exactly. You may need to use the OnAction API function to ensure that Windows opens the file with the proper program.

Colin Legg
04-25-2008, 06:45 AM
Exactly. You may need to use the OnAction API function to ensure that Windows opens the file with the proper program.

Perhaps you could use the workbook object's followhyperlink method?

Mill
04-25-2008, 06:50 AM
Perhaps you could use the workbook object's followhyperlink method?

Wow. Sure enough. I'd never heard of that method before. Is it new?

Colin Legg
04-25-2008, 06:58 AM
Gosh, now you're asking Mill! :)

I believe it was around in Excel 97 [but don't take my word for it].

Mill
04-25-2008, 07:09 AM
Gosh, now you're asking Mill! :)

I believe it was around in Excel 97 [but don't take my word for it].

That could have saved me a minor bit of typing at one point. I got comfortable with the ShellExecute API back when I was using VB 3.1 or something like that.

Ooh, and the FollowHyperLink method is available in Access as well. Nice.

And it also works with e-mail addresses. It may not have all of the flexibility of the ShellExecute function (I'm not sure yet, though), but I'd prefer to use inherent functions instead of API if I can.

Colin Legg
04-25-2008, 07:16 AM
Just did a quick google and it was around in Excel 97 although it was a bit buggy when using "Mailto:" / method:=msoMethodPost.

http://support.microsoft.com/kb/161324

metropol
04-28-2008, 02:08 AM
Anyway. This means that I have to crate a Sub for each menuitem

Colin Legg
04-28-2008, 03:39 AM
Anyway. This means that I have to crate a Sub for each menuitem

Correct metropol, and you are welcome.

Mill
04-28-2008, 06:15 AM
For some reason, I thought you could use Application.Caller from a sub called by a menu click. However, I couldn't make it work it my mini-test, and didn't find anything to support my pseudo-memory of such.

Colin Legg
04-28-2008, 12:01 PM
For some reason, I thought you could use Application.Caller from a sub called by a menu click. However, I couldn't make it work it my mini-test, and didn't find anything to support my pseudo-memory of such.

Of course you could use a 'communal' subroutine for the "menuitems" rather than individual routines - my confirmation was meant more towards the notion that you can't anchor a hyperlink to a "menuitem" :)

metropol
05-06-2008, 04:14 AM
Thank you for helping me out with this one. I have no a working routine, using followhyperlink.

Best Regards

Colin Legg
05-06-2008, 04:28 AM
Thank you for helping me out with this one. I have now a working routine, using followhyperlink.

Best Regards

Great work Metropol! :cool: .... I'm glad we were able to help you! :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum