AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Would you like to create a hyperlink to your favourite website on a form using VBA?
Thought so!
Open a new project in VBA and insert a new Userform.
Add a label to the form and change the caption to the URL of your website.
e.g. http://www.afralisp.com
Change the colour of the label to Blue - Underlined.
Now add the following coding to the click event of the label :

'<- Coding Starts Here

Private Sub Label1_Click()
Dim nFile As Integer

'Write a temp file URL
nFile = FreeFile

Open "TEMP.URL" For Output As #nFile
Print #nFile, "[InternetShortcut]"
Print #nFile, "URL=http://www.afralisp.com"
Close #nFile

'Launch the browser
Shell "rundll32.exe shdocvw.dll,OpenURL " & "\temp.url", vbNormalFocus

'Delete the temp file
Kill "TEMP.URL"

End Sub

' Coding Ends Here

Voila, you have a hyperlink on your form.

 
The AutoLisp/Visual Lisp/VBA Resource Website

Copyright © 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website