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.