I had written a program to create a commandbar from VBA. It was in X4 and executed well. The program with
Dim CmdBar As CommandBarDim CmdBtn As CommandBarControl
now does not run in X5. Says "User defined type not defined. I cannot find the way to set a variable for commandbar and commandbarcontrol. How can I do it in X5.
Hi Anand,
ok, I started to actually think instead of looking for the answer. For starters you can replace
Dim CmdBar As CommandBar
with
Dim app As ApplicationSet app = CorelDRAW.Applicationapp.CommandBars.Add
I just tested this and it works. I have not looked at the 2nd part yet, but will do so now.
Best regards,Brian
I have got this far now:
Sub CreateCmdbar()Dim app As Application
Set app = CorelDRAW.Applicationapp.CommandBars.Add ("Anand 1")app.CommandBars("Anand 1").Controls.Add "View", 1, Falseapp.CommandBars("Anand 1").Visible = True
End Sub
It creates a toolbar named "Anand" just fine and the last line (just before End Sub) shows it on the page. The only line I am struggling with is:
app.CommandBars("Anand 1").Controls.Add "View", 1, False
I named the button "View", 1 is the index (I guess button 1 on the toolbar, so I chose "1"), false was for the option "temporary" = true/false. When I run the code I get a toolbar named "Anand", but with no button on it. Maybe you or John can figure it out. I will have a play after I make a cup of coffee.
Best regards,Brian.
I forgot to come back to this thread earlier on, I have been posting in other threads and testing some bugs. This was the last code I had reached before retiring for awhile..lol:
Sub CreateCmdbar()
Dim app As ApplicationSet app = CorelDRAW.Applicationapp.CommandBars.Add ("Anand 1")
With app.CommandBars("Anand 1") .Controls.AddCustomButton "Button 1", Year(2011), 1, False .Controls.AddCustomButton "Button 2", Month(1), 2, False .Controls(1).Visible = True .Visible = TrueEnd With
It creates the toolbar and 2 buttons, but the buttons must be the same colour as the toolbar because they are not visible. However, hovering over them reveals they are actually there. Maybe have a play around from here, I will do the same tomorrow evening. I need to get some sleep as I have an appointment in the morning first thing and it is 1.05am here.
you can disable a button without making it disappear?I have to make sure that the icon is turned off but visible.commandbar not (). controls (). visible but> commandbar (). controls (). enabled?