Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Is there a way to create a simple button on UI that calls out/show my userform?
Thank you and k.rgds,
Solved! Go to Solution.
Hi,
Is there a way to create a simple button on UI that calls out/show my userform?
Thank you and k.rgds,
Solved! Go to Solution.
There's basically two ways.
1. Use VBARUN command for the button macro. Search this forum for VBARUN.
2. Create a lisp command wrapper for the vba and then call the command in the button macro. The advantage of this method is that you can type the command at the command line and use {Enter} to repeat the command.
Or are you asking how to show your form?
In a separate Sub, you create an instance of it and then use it's Show method. Then call the main sub using one of the two methods above.
Dim frm As myForm
Set frm = New myForm
frm.Show()
Hi Ed,
I would like to create a new ribbon panel with some buttons that would be able to call/show my userform that I made on VBA manager.
is there such a way how to create a custom button on the panel ribbon and call out/show such userform?
thank you and kind regards,
Not with VBA, but C# you can. For VBA, you just have to create a ribbon panel and button macro using the CUI. Please read my tutorial that I linked to.
Did my answer provide you a solution?
Hi Ed,
I'm a bit of confused actually.
an example module that contains
sub showForm()
showMyForm.show
end sub
so i will just add this "showForm" on the lisp that you gave? then i can call out the command on acad is that how it works?
Btw here is your lisp
;;; get the application object
(setq *acadObj* (vlax-get-acad-object))
;; array of command name strings
(setq CommandList
(list
"showForm" "Command2"
"Command3" "Command4"
"Command5" "Command6"
)
)
;; make a defun for each command name
(foreach CommandName CommandList
(eval
(list 'defun
(read (strcat "C:" CommandName))
'()
(list 'vla-RunMacro *AcadObj* CommandName)
'(princ)
)
)
)
can you enlighten me for a bit?
Correct, but you will need to get rid of the other command strings you're not using. e.g. "command2".
You put this lisp in an mnl file named the same as your cuix, and it will load when your menu loads. Then you can click on your ribbon button or type showform at the command line.
P.S. When posting code in the forum, please use the code window. The button looks like </>. It keeps the formatting and color coding.
;;; get the application object
(setq *acadObj* (vlax-get-acad-object))
;; array of command name strings
(setq CommandList
(list
"showForm"
)
)
;; make a defun for each command name
(foreach CommandName CommandList
(eval
(list 'defun
(read (strcat "C:" CommandName))
'()
(list 'vla-RunMacro *AcadObj* CommandName)
'(princ)
)
)
)
Hola, sí hay una manera para crear un botón en autocad y puedas ejecutarlo presionando clic. Este video es ilustrativo y muy útil para tu pregunta pero está en español. Aquí te dejo el link https://youtu.be/D9TAwjslTE4