PDA

View Full Version : MS Excel - Help Required


Supervox
01-03-06, 05:29 PM
I need to create 6 buttons in a spreadsheet each with a hyperlink to a different webpage.
Unfortunately, I know NOTHING about Visual Basic. :(

I am sure that one of you will take pity on me & help me out !! :D

TSM
01-03-06, 06:11 PM
I have only ever needed one form button to a site, but you could get more easly. There may be a better way to do this.

Go into the VB editor under Macros and add the folowing code.
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


Create extra lines using this code under the code added above, change the GotoURL to something diffrent for each url and also modify the url.
Sub GotoURL()
ShellExecute 0&, vbNullString, "www.google.co.uk", vbNullString, vbNullString, SW_SHOWNORMAL
End Sub

Create a form button and assign it to a macro to go to a certian website.
It will open the default browser and show the site.

This is a long winded way but i cant remember how to pass variables from the form button into VB so the code does not have to be as long.

Blue Flame
01-03-06, 06:47 PM
Don't think you need to go to all that bother.

Just create your own buttons using the draw toolbar facility. Right click on each of the finished images and click on the 'hyperlink' option to add your web pages in.

Job done :thumbsup:

TSM
01-03-06, 07:07 PM
I think you cant do that , I tried it in my excel, the Hyperlink option does not come up for form buttons.

PS. Ah sorry misread your message, yep if its a drawn object then yes you can, but if its a form button you cant. But using the drawn box does not give the same clicky effect that a form button would.

Supervox
01-03-06, 07:51 PM
Thanks for your help guys - the button DOES need to look as though it's been 'pushed' - lots of people with even less idea than me are gonna be using these links !!

Cheers !! :D

Rob S (Yella)
01-03-06, 10:30 PM
Thanks for your help guys - the button DOES need to look as though it's been 'pushed' - lots of people with even less idea than me are gonna be using these links !!

Cheers !! :D

You could put a macro/vb on the button so when it's pressed it changes colour or gets a shadow effect so you can tell its been pressed. You might need another to reset the buttons to the default colour/type when you close the sheet.

Thats how I would do it but there must be easier and more more efficient ways to do it.

Blue Flame
01-03-06, 11:52 PM
OK I've got the answer for this one.

Use the 'Controls Toolbox' toolbar to add a 'command button' to your spreadsheet. (IE not the forms toolbar)

You are then able to use the hyperlink button on the 'standard' toolbar to assign a web page to the button you have just created. (Note that the 'right click menu' does not give you the option for hyperlink therefore you must use the hyperlink button on the standard toolbar)

Hope this is of use.

TSM
01-03-06, 11:58 PM
That does not work either, just tried it.

Well it does and does not work. If you are still in Design Mode then it will work, when you exit Design Mode it stops working.

Blue Flame
02-03-06, 12:01 AM
That does not work either, just tried it.

Well it does and does not work. If you are still in Design Mode then it will work, when you exit Design Mode it stops working.

Hmm i'm confused with that. It seems to work for me. I assume that clicking anywhere else on the spreadsheet takes it out of design mode? Cos after I have done that the link works. :?

OOPs strike that. Back to the drawing board