running a VBA command from a ribbon created with .net
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello every one
I have a program which creates a ribbon and a bunch of buttons in it. I want the program to run a VBA application when I click on the buttons.
the program has a command handler and I dont know how to assign my VBA path to it.
public class RibbonCommandHandler : System.Windows.Input.ICommand
{
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
if (parameter is RibbonButton)
{
RibbonButton button = parameter as RibbonButton;
doc.Editor.WriteMessage("\nRibbonButton Executed: " + button.Text + "\n");
if(button.Text == "Pendent")
{
//acadApp
doc.SendStringToExecute("_.vbarun;C:/NSV/CODES/P.dvb!P.P", true, false, true);
//^C^C_.vbarun;C:/NSV/CODES/P.dvb!P.P
}
if (button.Text == "Side")
{
doc.SendStringToExecute("vbarun;C:/NSV/CODES/P.dvb!P.P", true, false, true);
}
}
}
}
PS. the code is not mine. but I know I have to omit the part which says doc.editor.writemessage("\n ...")
but my problem is typing, apart of the code, even typing "^C^C_.vbarun;C:/NSV/CODES/P.dvb!P.P" in the command line is not working. even though I created a button in the CUI and i assigned this to it, and it works perfectly fine.