Serving the Quantitative Finance Community

 
User avatar
thepay
Topic Author
Posts: 0
Joined: September 5th, 2001, 6:53 am

VBA Questions

September 20th, 2002, 5:10 pm

Hi, is it possible for me to create a menu bar and put it in a position I like? I know I could put it in some pre-defined position(top,right, etc) but is it possible to put it in some arbitrary position instead of those?Also, I tried to create a menu bar in a macro and it worked successfully but when i tried to copy the code to the private sub workbook_open. it didn't work. Why is that so?? it appeared something like object doesn't support the method, etc.Also, I have got a number of similar objects in my user form(say combo boxes). Is it possible for them to run same subroutine when the change value?? since i have to define combobox1_change and combobox2_change individually for every one of them. is it possible to have a general subroutine for all of them? i currently define a general one and in every individual subroutine, i call the general subroutine. is there a better way to achieve it?Thanks veyr much.
 
User avatar
gregorios
Posts: 0
Joined: September 20th, 2002, 1:15 pm

VBA Questions

September 20th, 2002, 9:52 pm

Q1: Did you try using the .Left & .Top properties of the Command Bar? e.g. CmndBr.Left =218 where CmndBr is a Command Bar Object.Q2: Hard to tell what's the problem. Will you show the exact code?Q3: I think what you've done is best possible. Maybe by putting the whole family of same controls in a frame the "Change" event will bubble-up to the frame and you pick it up from there. Doubt it will work though.
 
User avatar
thepay
Topic Author
Posts: 0
Joined: September 5th, 2001, 6:53 am

VBA Questions

September 23rd, 2002, 1:23 am

It is:Set cbar1 = CommandBars.Add(Name:="Custom1", Position:=msoBarFloating)cbar1.Visible = Trueand the error message is Object variable or With block variable not set
 
User avatar
thepay
Topic Author
Posts: 0
Joined: September 5th, 2001, 6:53 am

VBA Questions

September 23rd, 2002, 4:16 am

Anyway, I have asked the workbook_open subroutine to call the other subroutine and it works. so i won't bother with this anymore. thanks for help.However, I could resize the menubar even if i set its width and height in the codes. how could i achieve this? I didn't set protection for the menu bar. thanks.
 
User avatar
gregorios
Posts: 0
Joined: September 20th, 2002, 1:15 pm

VBA Questions

September 23rd, 2002, 4:26 pm

I assume you are attempting to resize the command bar programmatically rather than interactively ( by the way, you can resize it interactively once it's created, TRUE ? ).I'm afraid I have no suggestions on this one.Good luck.