Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding items to a menu at run-time

Menus

Adding items to a menu at run-time

by  JESTAR  Posted    (Edited  )
Open your Menu Editor. I'm using a Bookmark system as an example, you can add URL's to your menu then open Internet Explorer straight to that page. Adapt it as you wish.

Set up this in your Menu Editor, the Indexes are what you need to add:

Bookmark (name= mnuBookmarkTop)
...Add a Bookmark (name = mnuBookmark, Index = 0
...Launch Internet Explorer (name = mnuBookmark, Index = 1)
...- (name = mnuBookmark, Index = 2)

The names are the same, so it's a control array. Now to add the items. I used an InputBox here. The user enters the URL, and it appears on the menu under the last item. They can then click it to open IE to that page. Here's the code:

[tt]Private Sub mnuBookmark_Click(Index As Integer)
Dim Bookmark As String
Dim I As Integer

Select Case Index
Case 0:
[color green] 'Display the InputBox for the user to enter the URL[/color]
Bookmark = InputBox("Enter the URL to Bookmark", "Bookmark a website")
[color green] 'Get the next available index in the menu[/color]
Load mnuBookmark(mnuBookmark.ubound + 1)
[color green] 'Write the Caption of the new item as the URL[/color]
mnuBookmark(mnuBookmark.ubound).Caption = Bookmark
Case 1:
Shell ("C:\Program Files\Internet Explorer\IExplore www.google.com"), vbMaximizedFocus
Case Else
Shell ("C:\Program Files\Internet Explorer\IExplore " & mnuBookmark(Index).Caption), vbMaximizedFocus
End Select
End Sub[/tt]

That's it.


Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top