muy buen video , muy pocos aclaran este tipo de temas de crear eventos personalizados, justo venia investigando como incluir eventos personalizados a un proyecto. Eh visto un par de líneas que me parecieron muy interesantes el echo de instanciar un objeto y usar la función Create como un constructor es algo que se puede hacer de manera sencilla en Python pero en VBA no lo había visto antes y tenia la necesidad de implementar algo parecido. Muy agradecido por el aporte.
también me pareció interesante que hayas personalizado la cinta de opciones del VBE, voy a buscar en tus videos como personalizarlo, claro si ya subiste videos de como hacerlo, en todo es muy bien material para compartir, considero que a esa cinta del VBE le faltan algunas opciones mas.
Hi Ismail. I have a question for you. I created a class module with my own custom Button click_event. The class uses Public withevents. Plus my own custom Mouse_Down event. This is for Activex buttons that will do something when I click on them or right click on them. There are up 480 buttons at one time that's why I used the class so I didn't have use the click_event for each one. I have Other modules that will performer other actions. Everything works fine. The Issue I am having is when I click on the Save icon up on the command bar. It says it saved to my PC but when I go close it buy hitting the X in the corner or by going to the left and click on the close. I get the Popup message do you want to save this file. with the options. Save, Don't Save, Cancel. No matter how many times I click on the save file icon it doesn't seem to save the file. I know it has something do with the class module because I Ran the macros without it calling the class all the other modules were called and the functions were performed. the only thing that doesn't work is the Button Click_Event and the MouseDown_Event which is controlled by the Class Module. Now when Click on the save icon it saves fine I don't get the popup message that says do you want to save this file. As soon as I reactivate the Class Module and try to save it then the popup message is back. Oh I Also have the Class to Set MyClass = Nothing After the Class is Called and on the WorkBook_Events BeforeClose and AfterSave_Event. I Still Get the Popup. Do you have any suggestions. Thanks.
@@mdismailhosen8280 oh, I thought Rubberduck has added this functionality. By the way, is this custom ribbon/commands available as an addin or do you have a github repo?
If you do not want to reinvent the wheel. Rubberduck has already this feature. Right-click variable and from rubberduck select "Encapsulate Variable/Member" it has the effect that your button is doing.
@@VipulKarkar encapsulate and constructor is not same thing. See rubber duck github repo. I have created an issue for constructor and they flag it as new feature.
I've never seen it explained so easily. thank you But I think there is one more thing I need to learn. I copied and pasted the code into the file exactly like the teacher's code, but... EventDriver module Set CurrentPerson = Person.Create("Md.Ismail Name", 27) The above code does not recognize Person. An error message appears saying the variable is not defined. so... Dim CurrentPerson As New Person Set CurrentPerson = CurrentPerson.Create("Md.Ismail Name", 27) After modifying it like this, it works fine. What's the problem? If you download the teacher's file and run it, it will work. At that place... Dim CurrentPerson As Person Set CurrentPerson = Person.Create("Md.Ismail Name", 27) This is what happened and it worked well. '@PredeclaredId Is there something else that needs to be set in the VB editor to use this?
Thank you. It means a lot to me. In the main file we have a metadata set to true which you can't see in the VBE Editor. That's what this PredeclaredId means. You need to do some google on PredeclaredId or watch my Factory method pattern video.
muy buen video , muy pocos aclaran este tipo de temas de crear eventos personalizados, justo venia investigando como incluir eventos personalizados a un proyecto. Eh visto un par de líneas que me parecieron muy interesantes el echo de instanciar un objeto y usar la función Create como un constructor es algo que se puede hacer de manera sencilla en Python pero en VBA no lo había visto antes y tenia la necesidad de implementar algo parecido. Muy agradecido por el aporte.
Glad to help.
thank you so much for useful video training
Welcome.
también me pareció interesante que hayas personalizado la cinta de opciones del VBE, voy a buscar en tus videos como personalizarlo, claro si ya subiste videos de como hacerlo, en todo es muy bien material para compartir, considero que a esa cinta del VBE le faltan algunas opciones mas.
Please share your ideas to include in the video.
Thanks for the video. I'm curious, how did you get the Create function to work? I tried to recreate it and I get an error Object required.
Can you check if any difference is there in your code and my code?
Hi Ismail. I have a question for you.
I created a class module with my own custom Button click_event.
The class uses Public withevents.
Plus my own custom Mouse_Down event.
This is for Activex buttons that will do something when I click on them or right click on them.
There are up 480 buttons at one time that's why I used the class so I didn't have use the click_event for each one.
I have Other modules that will performer other actions.
Everything works fine.
The Issue I am having is when I click on the Save icon up on the command bar.
It says it saved to my PC but when I go close it buy hitting the X in the corner or by going to the left and click on the close.
I get the Popup message do you want to save this file. with the options. Save, Don't Save, Cancel.
No matter how many times I click on the save file icon it doesn't seem to save the file.
I know it has something do with the class module because I Ran the macros without it calling the class all the other modules were called and the functions were performed.
the only thing that doesn't work is the Button Click_Event and the MouseDown_Event which is controlled by the Class Module.
Now when Click on the save icon it saves fine I don't get the popup message that says do you want to save this file.
As soon as I reactivate the Class Module and try to save it then the popup message is back.
Oh I Also have the Class to Set MyClass = Nothing After the Class is Called and on the WorkBook_Events BeforeClose and AfterSave_Event.
I Still Get the Popup.
Do you have any suggestions.
Thanks.
It’s really hard to understand the reason without seeing the code.
@@mdismailhosen8280
Do you have an email
1997ismail.hosen@gmail.com
Hi, friend!
Tell me how did you customize your VBE ?
I am using Microsoft Extensibility 5.3 and a lot of my code.
What is the toolbar name that your are using for "Insert Constructor"?
Oh. It's not built in. It's my custom toolbar created by me.
@@mdismailhosen8280 oh, I thought Rubberduck has added this functionality. By the way, is this custom ribbon/commands available as an addin or do you have a github repo?
@@VipulKarkar It's in my personal addin. Not publically available. I have plan to release my addin in near future.
If you do not want to reinvent the wheel. Rubberduck has already this feature. Right-click variable and from rubberduck select "Encapsulate Variable/Member" it has the effect that your button is doing.
@@VipulKarkar encapsulate and constructor is not same thing. See rubber duck github repo. I have created an issue for constructor and they flag it as new feature.
I've never seen it explained so easily. thank you
But I think there is one more thing I need to learn.
I copied and pasted the code into the file exactly like the teacher's code, but...
EventDriver module
Set CurrentPerson = Person.Create("Md.Ismail Name", 27)
The above code does not recognize Person.
An error message appears saying the variable is not defined.
so...
Dim CurrentPerson As New Person
Set CurrentPerson = CurrentPerson.Create("Md.Ismail Name", 27)
After modifying it like this, it works fine.
What's the problem? If you download the teacher's file and run it, it will work.
At that place...
Dim CurrentPerson As Person
Set CurrentPerson = Person.Create("Md.Ismail Name", 27)
This is what happened and it worked well.
'@PredeclaredId
Is there something else that needs to be set in the VB editor to use this?
Thank you. It means a lot to me. In the main file we have a metadata set to true which you can't see in the VBE Editor. That's what this PredeclaredId means. You need to do some google on PredeclaredId or watch my Factory method pattern video.