VBA UI UX-19: How to add Right-click context menu to UserForm Controls

Поділитися
Вставка
  • Опубліковано 4 січ 2025

КОМЕНТАРІ • 90

  • @ionascurazvan3980
    @ionascurazvan3980 3 роки тому +1

    Didn't know you can actually add this in user forms. You make it look so easy. Great job!

  • @Leynad
    @Leynad 3 роки тому +3

    You are doing an exceptional job and your channel is a wealth of knowledge, thank you very much for work.

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      You are very welcome

  • @vicsg8621
    @vicsg8621 3 роки тому +1

    very useful.I needed this solution since the latest version of excel do not support the date picker in userform control

  • @Rahul-sn1wn
    @Rahul-sn1wn 3 роки тому +1

    Thanks for another useful tutorial. Will check back later for project

    • @VBAA2Z
      @VBAA2Z  3 роки тому +1

      Cool, thanks

  • @ernestniinai
    @ernestniinai 3 роки тому +1

    Exactly what I need. Good job very clean.

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Thanks! 👍

  • @GuyDus-ti8nb
    @GuyDus-ti8nb 7 місяців тому

    excellent work, many successes in all

    • @VBAA2Z
      @VBAA2Z  7 місяців тому

      Many many thanks

  • @BuzzKent
    @BuzzKent 3 роки тому

    These videos are exceptional. Thank you

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Glad you like them! Thanks for watching.

  • @mrparkour2016
    @mrparkour2016 2 роки тому +1

    really great job thx 4 this info bro

    • @VBAA2Z
      @VBAA2Z  2 роки тому

      Glad it helped

  • @hoseal8048
    @hoseal8048 3 роки тому

    Thanks as always. Appreciate sharing your knowledge with us

    • @VBAA2Z
      @VBAA2Z  3 роки тому +1

      So nice of you, thanks

  • @marinokranjcec7210
    @marinokranjcec7210 3 роки тому +1

    Amazing. Very useful to know.

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Glad it was helpful!

  • @kingsoko5319
    @kingsoko5319 2 роки тому +1

    Thank you Pamai

    • @VBAA2Z
      @VBAA2Z  2 роки тому

      You are so welcome

  • @holieh5301
    @holieh5301 3 роки тому +1

    Never knew about this. thank you

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Glad it was helpful! thanks for watching

  • @azel2239
    @azel2239 3 роки тому +1

    Thanks for sharing your knowledge

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      My pleasure

  • @westernmukesh
    @westernmukesh 2 роки тому +1

    Hello, the video is great!, this video tells how to add right click pop-up menu. Can you pl tell me how to add a right click pop-up menu for a ListBox Item (i.e., each entries in the list box)?

    • @VBAA2Z
      @VBAA2Z  2 роки тому

      Let me check

  • @stefanogattoCH
    @stefanogattoCH 3 роки тому +1

    Thank you for the nice and clear video! I tried on Excel 365 but it doesn't compile the VBA Project because it does not find "msocontrolbutton"... It looks like some library is missing. Do you know how to load it?

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      If it's having trouble with msoControlButton then set a reference to Microsoft Office 16.0 Object Library. your version might be different.

    • @stefanogattoCH
      @stefanogattoCH 3 роки тому

      @@VBAA2Z It works!!! Thank you very much!!!

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      You're most welcome.

  • @mohammedelsayed3852
    @mohammedelsayed3852 3 роки тому +1

    عمل رائع
    جزاك الله خيرا و انار قلبك

    • @VBAA2Z
      @VBAA2Z  3 роки тому +1

      God bless

  • @VBAbyMBA
    @VBAbyMBA 2 роки тому +1

    HI! thanks for the VBA, I have tried it on windows it works perfectly however it does not on Mac, is there anything that I am missing? please help

    • @VBAA2Z
      @VBAA2Z  2 роки тому +1

      Sorry I don't have Mac to test this

  • @SaraPerzYT
    @SaraPerzYT 3 роки тому +1

    Thanks sir. It’ll be very useful

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Always welcome

  • @kinga334
    @kinga334 3 роки тому +1

    Great videos. Thanks

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Thanks for watching!

  • @ahmetatasay9217
    @ahmetatasay9217 3 роки тому

    Harika Videolar... Çok Teşekkürler....
    Great Videos ... Thank you very much... :)

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      You're welcome Ahmed. thanks for watching

  • @mrashid229
    @mrashid229 3 роки тому +1

    A very useful one!

    • @VBAA2Z
      @VBAA2Z  3 роки тому +1

      Glad it was helpful! thanks for watching

    • @mrashid229
      @mrashid229 3 роки тому

      @@VBAA2Z Not just for Cut/Copy/Paste/Select, this way form specific buttons (e.g. Add, Edit, Save, Delete etc.) can be defined to save space on the form. I guess the popup menu can be made appear on a specific location on the form, isn't it (not on right-click) ??
      Possibly private sub/function inside the form can also be triggered by .OnAction=""... right?

    • @VBAA2Z
      @VBAA2Z  3 роки тому +1

      Yes you can. example below for menu anywhere in UserForm. Replicate as many items as needed.
      Private Sub UserForm_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
      PopRightClickMenu
      End Sub
      More menu examples/sample download here
      ua-cam.com/video/Cia-EO6KpFA/v-deo.html

  • @coffian5
    @coffian5 3 роки тому

    thank you so much for the GREAT things!

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      You are so welcome!

  • @Chandan7404
    @Chandan7404 2 роки тому +1

    This way we cannot call a "Private Sub" within the UserForm but only Public Subs in regular Code Modules, am I right?

  • @kestanaluekitna9462
    @kestanaluekitna9462 2 роки тому +1

    I try this code to my form but it has error 424 (object required). how to solve it?

    • @VBAA2Z
      @VBAA2Z  2 роки тому

      You can share your code and point me to the line causing error

  • @zitomoreno9408
    @zitomoreno9408 3 роки тому +1

    Great job, i finished my ui/ux userform with richtextbox to send email without exit to excel, if you wannna see, tell me!

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Thanks Zito. Email id is in video description

  • @suraksha7841
    @suraksha7841 3 роки тому +1

    Your video's are beyond the thinking. Thanks for sharing all this valuable information with us.
    Just have one question:
    Is it possible to automatically adjust the column size in a multi-column listbox based on data that is inserted? I know only the static one. Have search the internet, but couldn't find something which I can understand. I know that the answer is yes, but how to code it. Can you please help me with this. (Suggestion: Maybe a video on this). Many thanks in advance.

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Check out this Listbox video:ua-cam.com/video/ZMLIr3UZOEI/v-deo.html
      There is no AutoFit method, so to get around this would be to scan your data input and use its LEN to set the size. Below is the sample of adding 3 columns with column width.
      Me.ListBox1.ColumnCount = 3
      Me.ListBox1.ColumnWidths = "30,70,70"

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      try and replicate something like this.
      ua-cam.com/video/U1sQ1-Oa0fs/v-deo.html

    • @suraksha7841
      @suraksha7841 3 роки тому +1

      Thank you for the quick reply. I wil look forward on the internet. The listview would be a great option if it would work on 64 bit. Thats the issue when you build a excel application which will be used by many people.

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      ListView works in 64bit Excel. Simply install Common Controls provided in
      ua-cam.com/video/QGZqjUGhJ1Q/v-deo.html
      www.microsoft.com/en-us/download/confirmation.aspx?id=10019

  • @essibaba1
    @essibaba1 7 місяців тому

    Great job

    • @VBAA2Z
      @VBAA2Z  7 місяців тому

      Thanks!

  • @baliongerewiong2194
    @baliongerewiong2194 3 роки тому +1

    Brother this is something new I have not seen thankyou for the amazing video, how do I download the right click menu file

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      You're most welcome. please check link in the description.

  • @dwsteyl
    @dwsteyl 3 роки тому +1

    Superb

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Thank you! Cheers!

  • @rahulshewale9206
    @rahulshewale9206 3 роки тому +1

    Thank you sir

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      You're welcome! thanks for watching

  • @abdelghani9556
    @abdelghani9556 3 роки тому +1

    Thanks a lot

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Most welcome

  • @s.a.designconsult2620
    @s.a.designconsult2620 2 роки тому

    Hello sir, I try such but it's showing Run time error 5
    Invalid procedure call or argument

    • @VBAA2Z
      @VBAA2Z  2 роки тому

      where (which module and procedure name) are you facing this error?

    • @s.a.designconsult2620
      @s.a.designconsult2620 2 роки тому

      @@VBAA2Z in
      With commandbars.add (msocontrolbutton)

    • @s.a.designconsult2620
      @s.a.designconsult2620 2 роки тому

      Sir it latter work perfectly thank you
      But when I am calling my macro e g that's onaction = "myname" it's saying that such macro is not available in the work but it's there

  • @thenebu
    @thenebu 2 роки тому

    Everything works, except of the PopupMenu istn't vanishing after a selection. Wrote the exact same code as you....

    • @VBAA2Z
      @VBAA2Z  2 роки тому

      Check the object click sub routine

  • @GoncaloFly
    @GoncaloFly 3 роки тому

    Cool 😎

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Cool 😎😎

  • @GunjanMehta2084
    @GunjanMehta2084 Рік тому

    thanks

    • @VBAA2Z
      @VBAA2Z  Рік тому

      You're welcome!

  • @jaredkulavich6081
    @jaredkulavich6081 3 роки тому +1

    Thanks for amazing contents.
    Please share tips to automate VBA undo / Ctrl Z

    • @VBAA2Z
      @VBAA2Z  3 роки тому

      Will upload soon - thanks for your suggestion and visit.

  • @silunewmai9017
    @silunewmai9017 3 роки тому

    Thanks

  • @kevinplant5590
    @kevinplant5590 Рік тому

    Hi
    This is exactly what I'm looking for but for some reason my "Copy" macro doesn't work (Copy is the only option I want on the menu).
    The popup menu shows and then goes when clicked but the txtBox contents are not on the clipboard.
    Code below if anyone can help with where I've gone wrong?
    Thanks heaps!
    Option Compare Text
    Public txtObj As MSForms.TextBox
    Const menuName As String = "tempMenu"
    Sub DeleteMenu()
    On Error Resume Next
    CommandBars(menuName).Delete
    On Error GoTo 0
    End Sub
    Sub PopRightClickMenu()
    DeleteMenu
    With CommandBars.Add(menuName, msoBarPopup)

    With .Controls.Add(msoControlButton)
    .OnAction = "tbox_copy"
    .Caption = "Copy"
    End With
    .ShowPopup
    End With
    DeleteMenu
    End Sub
    Private Sub txt_bus_name_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Button = 2 Then
    Set txtObj = txt_bus_name
    PopRightClickMenu
    End If
    End Sub
    Private Sub txt_email_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Button = 2 Then
    Set txtObj = txt_email
    PopRightClickMenu
    End If
    End Sub
    Private Sub txt_name_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Button = 2 Then
    Set txtObj = txt_name
    PopRightClickMenu
    End If
    End Sub
    Private Sub txt_phone_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Button = 2 Then
    Set txtObj = txt_phone
    PopRightClickMenu
    End If
    End Sub
    Private Sub UserForm_Initialize()
    txtBox_search.SetFocus
    End Sub
    Private Sub UserForm_Terminate()
    Set txtObj = Nothing
    End Sub
    Public Sub tbox_copy()
    txtObj.Copy
    End Sub

    • @VBAA2Z
      @VBAA2Z  Рік тому

      code looks fine. any error message?

  • @elhachemiazara2610
    @elhachemiazara2610 2 роки тому +1

    THANKS

    • @VBAA2Z
      @VBAA2Z  2 роки тому

      You're welcome!