|
-
Sep 29th, 2009, 07:04 AM
#1
Thread Starter
Member
Please help with menu bar
Hi there Gurus!
I have surfed the net searching how to add Menu like "File", "Tools", "View" etc.
But all i have found is how to make a tools bar for the developer to use.
Mey be anybody can help me with that. Where to start from?
What contril type is it and where to declare it.
Thanks in advance!
Ruslan.
Last edited by ruslannurijev; Sep 29th, 2009 at 08:31 AM.
-
Sep 29th, 2009, 04:51 PM
#2
Re: Please help with menu bar
the menu is commandbar
there are examples in the tutorial for adding commandbars and commandbar buttons etc
vb Code:
Dim cb As CommandBar For Each cb In Application.CommandBars Debug.Print cb.Name Next
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 30th, 2009, 12:49 AM
#3
Re: Please help with menu bar
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 30th, 2009, 01:46 AM
#4
Re: Please help with menu bar
Hi
Do you want to add menus to Excel Toolbar/Commandbar or a Userform?
If it is Toolbar/Commandbar then follow Rob's Tutorial, else if it is the latter then follow the link mentioned below...
http://www.vbforums.com/showthread.php?t=531789
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Sep 30th, 2009, 03:03 AM
#5
Re: Please help with menu bar
For UserForm I have one too just a bit farther down my FAQ 
http://www.vbforums.com/showthread.php?t=402050
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 30th, 2009, 03:30 AM
#6
Re: Please help with menu bar
@ruslannurijev: Now you have 3 options Take your pick...
One for the Worksheet menu Bar
One for the Userform menu which imitates the Worksheet menu Bar in Userform
One for the Context Menu in the Userform
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Sep 30th, 2009, 03:43 AM
#7
Re: Please help with menu bar
The VB Forums Search feature is better then Google
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 30th, 2009, 09:51 AM
#8
Re: Please help with menu bar
Absolutely Rob. I am with you on that. The VBF has a dearth of knowledge hidden it it's threads...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 1st, 2009, 01:58 AM
#9
Thread Starter
Member
Re: Please help with menu bar
Thank all of You guys/ladies!
Sorry for my late reply (was out of town).
I want to add menu on a user form.
I have tried to do some macros, but without experience i failed.
I don't even know where to type code or where to declare my new menu 
I agree with you that VBF is better than GOOGLE search, but surfing VB forum did not give expected result, it seems that i was looking in wrong place.
I haven't yet checked the links that you guys posted here, so i am going to do that right now. Meanwhile you could advice me in creating menus and sub menus.
Best regards,
Ruslan.
-
Oct 1st, 2009, 02:10 AM
#10
Re: Please help with menu bar
Meanwhile you could advice me in creating menus and sub menus.
Ruslan... But we already did....
Take your time and go through every links that Rob and I gave. Understand then and then try your code...
It's like you need to understand the recipe of "how to make a Pizza". We have given you recipes for different pizza types. Simply select the one that you want and understand it's recipe and then try it... If you get stuck simply ask
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 1st, 2009, 03:53 AM
#11
Re: Please help with menu bar
If you get stuck, please post up your questions and concerned code.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 1st, 2009, 07:53 AM
#12
Thread Starter
Member
Re: Please help with menu bar
Hi there!
I feel so stupid because i ckecked your links and i still can't get it!!!
In my FormLoad event i suppose to create a variable that refers to CommandBars collection, like:
Code:
Dim myCBar as CommandBars
Set myCBar = CommandBars.Add("Menu1", msoBarBottom)
then i make it visible:
Code:
myCBar.Visible = True
Well, after that my App gives errors, like:
"Type mismatch" or other erorrs
Really guys, i think i get things wrong about CommandBar(s) collection.
My logic is that first of all i make an object of CommandBar(s), then i make menu items on it like "File" or "Edit".
At the moment i can't figure it out how should i do it.
What does With block do?
What does For each block do?
If you guys, could just paste here sample code of doing menu like "File".
Then i would study your example and maybe this would help me understand the logic of creating menus on UserForms/Application forms.
Thank You in advance,
Ruslan.
-
Oct 1st, 2009, 07:57 AM
#13
Re: Please help with menu bar
Ruslan
Which type of menu do you want to make?
The Worksheet menu Bar OR
The Userform menu which imitates the Worksheet menu Bar in Userform OR
The Context Menu in the Userform (which you get when you right click)
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 1st, 2009, 08:14 AM
#14
Thread Starter
Member
Re: Please help with menu bar
The Userform menu which imitates the Worksheet menu Bar in Userform
not the context menu
Ruslan
-
Oct 1st, 2009, 09:22 AM
#15
Re: Please help with menu bar
ok... What are the options that you want in the menu...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 1st, 2009, 09:32 AM
#16
Thread Starter
Member
Re: Please help with menu bar
1 Menu "Options", that has submenus "Location" and "Group".
2 Menu "Export", that has submenu "Export document".
It must a drop-down list like in Internet Explorer "File" etc.
Thanks,
Ruslan.
-
Oct 1st, 2009, 10:15 AM
#17
Re: Please help with menu bar
Fine... Give me sometime. I am in the office at the moment. I will post a sample by the end of today
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 1st, 2009, 10:41 AM
#18
Thread Starter
Member
Re: Please help with menu bar
-
Oct 1st, 2009, 03:33 PM
#19
-
Oct 2nd, 2009, 02:05 AM
#20
Thread Starter
Member
Re: Please help with menu bar
Hey, Thanks KoolSid, i will study that code.
But actually i needed that code for Access 2000.
If your code is the same for Access then no problem, i will check it.
Thanks a lot!
PS!
if i have any questions, can i post em here?
Best regards,
Ruslan.
-
Oct 2nd, 2009, 02:10 AM
#21
-
Oct 2nd, 2009, 03:26 AM
#22
Thread Starter
Member
Re: Please help with menu bar
-
Oct 5th, 2009, 03:33 AM
#23
Thread Starter
Member
Re: Please help with menu bar
Hi there!
I have figured out the logic of creating menus(commandbar) for user forms in Access2000 but it still not working.
my code follows:
Code:
Private Sub Form_Load()
Dim myMenu As CommandBar
Dim myFileMenu As CommandBarButton
Set myMenu = CommandBars.Add("myMenuName", msoBarFloating)
Set myFileMenu = myMenu.Controls.Add(msoControlButton)
With myFileMenu
.Caption = "File"
.Style = msoButtonCaption
End With
myMenu.Visible = True
End Sub
i get an error: "Type mismatch"
and "Invalid procedure call or argument"
both these errors i get on this line:
Code:
Set myMenu = CommandBars.Add("myMenuName", msoBarFloating)
Any suggestions?
Regards,
Ruslan.
-
Oct 5th, 2009, 05:05 AM
#24
Re: Please help with menu bar
Hi I don't have access at the moment in Office. Will check this later on in the evening
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 6th, 2009, 07:01 AM
#25
Thread Starter
Member
Re: Please help with menu bar
Hi there guys!
Thanks for your help, but i was not just sitting and waiting for you to write me correct code.
I managed to get my commandbar working.
The problem was that if you once create commandbar "MyCommandBar" and run it, it is ok. But if you run it again then you get a "Invalid procedure call or argument" error. This is because command bar property name "MyCommandBar" already exists after first boot, and when you run app twice then code tries to create already created commandbar "MyCommandBar" and gives error.
All you have to do is delete commandbar "MyCommandBar" every time app starts.
Code:
Application.CommandBars("MyCommandBar").Delete
place this code before Set block.
So, i got my code working like this:
Code:
Dim myMenuBar As CommandBar
Application.CommandBars("MyCommandBar").Delete
Set myMenuBar = CommandBars.Add(Name:="MyCommandBar", Position:=msoBarTop)
myMenuBar.Visible = True
I quite pleased with that, but 1 problem still bothers me...
This command bar appears among other application menus, HOW CAN I GET THIS COMMAND BAR TO MY USERFORM?!?
Thanks in advance,
Ruslan.
-
Oct 8th, 2009, 12:23 PM
#26
Thread Starter
Member
Re: Please help with menu bar
Hi!
I read in internet that in access2000 u can't programmatically add CommandBars to UseForm. U can only add it to access application command bars, where other menus are such as File or Edit.
Is it true?
Thanks,
Ruslan.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|