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,
you will notice that if you start to type "Dim CmdBar As " and then the drop down code tips appear, there is no entry for CommandBar. I went into the VBA Editor and clicked F2 and did a search on CommandBar and found CommandBars. It was shown under Application, but if I clicked on CommandBars to read more about it I got this message:
I looked in References and there was no entry to tick for VGCore. Does this mean anything to you? Maybe John will know what is going on in X5.
Best regards,Brian.
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.
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.
Anand Dixit said: 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.
Check your references in Tools > References. Make sure they match the ones you have available in X4.
Specifically Microsoft Forms.
-John