OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 29-07-2003, 22:14
levin
Guest
 
Posts: n/a
Default How can I add a new menu to the coreldraw by the VBA

Hi All:

I want to add a new menu to the coreldraw , but I do't know how to do so ?

Thanks!
Reply With Quote
  #2  
Old 02-08-2003, 01:16
jmp
Guest
 
Posts: n/a
Default

Hi Levin,

afaik you can't

The CorelDraw 10 & 11 object models have a lot of classes like CommandBar(s), CommandBarControl(s), etc.
You can add a new CommandBar with the Add method, but you can't create a button or menu item into it :!:

I hope this will change with the next version...

Jean-Marie
Reply With Quote
  #3  
Old 03-08-2003, 19:47
levin
Guest
 
Posts: n/a
Default Thanks JMP

Hi JMP:

Thank for your reply, I will try to use CommandBar, It's also a method for my application.

Hope later version will change as AutoCAD VBA!
Reply With Quote
  #4  
Old 04-08-2003, 21:11
levin
Guest
 
Posts: n/a
Default How to user CommandBar to linke the VB Form

Hi JMP and Alex:

I have try go do as you tell me , but now I have meet a question again.
Here is the code which I Have written:

Dim cmdbar As commandbar
Set cmdbar= Application.CommandBars.Add("test")
cmdbar.Visible = True

How can add a new button the "test" command bar and link the button to a VBA form.
Thank you!
Reply With Quote
  #5  
Old 08-08-2003, 06:08
jmp
Guest
 
Posts: n/a
Default

Alas, I think you can't create a button into any CommandBar ! Perhaps with CorelDraw 12 ?

Jean-Marie
Reply With Quote
  #6  
Old 26-02-2005, 13:33
zlatev
Guest
 
Posts: n/a
Default

Topic revival: Anyone succeded with this in CorelDraw 12 :?:

Well I did

1. Searching for CommandBar (in order to prevent creating a CommandBar many times)
Code:
Private Function FindCommandBarByName(cName As String) As CommandBar
    Dim nIndex As Long
    For nIndex = 1 To Application.CommandBars.Count
        If (Application.CommandBars.Item(nIndex).Name = cName) Then
            Set FindCommandBarByName = Application.CommandBars.Item(nIndex)
            Exit Function
        End If
    Next nIndex
    Set FindCommandBarByName = Nothing
End Function
2. Creating a CommandBar
Code:
Dim oToolbar As CommandBar
Set oToolbar = FindCommandBarByName("ToolbarName")
If oToolbar Is Nothing Then
Set oToolbar = Application.CommandBars.Add("ToolbarName", cuiBarFloating, False)
End If

oToolbar.Visible = True 'Show it
3. Adding a button that will execute a given macro
Code:
Dim oButton As CommandBarControl
Set oButton = oToolbar.Controls.AddCustomButton _
("Macros", "GMSName.ModuleName.MacroName", 1, False)
Hope you find this useful
Other stuff like assigning keyboard shortcut keys is under research

Don't forget to add VBA referrence to VGCore (Corel - Vector Graphics Core 12.0 Type Library)
Reply With Quote
  #7  
Old 28-02-2005, 07:35
jmp
Guest
 
Posts: n/a
Default

Hi Zlatev,

Thanks for the tip ! When I am applying your code to an existing macro, I can see the bar, but the button is grayed.
However, if I add a new button by menu, this button is enabled !

Regards,

Jean-Marie
Reply With Quote
  #8  
Old 28-02-2005, 08:49
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Actually the category ID should be different, not "Macros".

This post will explain how to do it: http://www.oberonplace.com/forum/vie...hp?p=2235#2235
Reply With Quote
  #9  
Old 28-02-2005, 10:39
zlatev
Guest
 
Posts: n/a
Default

Well on my CDR12 it worked fine with category "Macros" (with capital M)
Also you should specify existing GMS name, module name and the public sub name instead of GMSName.ModuleName.MacroName in code

I also tested it with "2cc24a3e-fe24-4708-9a74-9c75406eebcd" - it works too.
The strange thing is that I cannot find neither IID, neither CLSID in registry with this value.
So it seems that this is neither Interface, nor Class in terms of Platform SDK meanings for Interface and Class.
Reply With Quote
  #10  
Old 01-03-2005, 03:22
jmp
Guest
 
Posts: n/a
Default

My mistake was to replace "Macros" with my own title ...

If I use "Macros" or the GUID as CategoryID, your code works fine with my french version.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CorelDraw 10 DXF export relative coordinates - VBA solution? asb617 CorelDRAW/Corel DESIGNER VBA 2 01-04-2010 02:34
CorelDraw 12 Menu items missing... lasergraver CorelDRAW/Corel DESIGNER VBA 2 22-04-2004 10:51
Accesing CorelDraw 10 VBA Object Model without running it dolmos CorelDRAW/Corel DESIGNER VBA 5 19-12-2003 07:52
Detect if VBA is installed (an answer and a question) reanan CorelDRAW/Corel DESIGNER VBA 3 04-12-2002 14:35
CorelDraw 11 VBA DOM? sdickson CorelDRAW/Corel DESIGNER VBA 2 03-12-2002 15:05


All times are GMT -5. The time now is 09:26.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com