Hello, againI have posted earlier my code to creating user form at runtime.
Hello,
Here is my code to create user form at runtime
Sub cbCreateUserForm()Dim vbeditor As VBESet vbeditor = Application.VBEDim stform As VBComponentSet stform = vbeditor.ActiveVBProject.VBComponents.Add(vbext_ct_MSForm) 'work create Form with standart name UserForm1, UserForm2 etc.stform.Name = "BhBpForm"stform.Properties("Caption") = "BhBpCaption"stform.Properties("BackColor") = vbRed
End Sub
Now i have one other question When starting first time, code is working well and the form BhBpForm was created
In Project Explorer i see just created BhBpFormThen I delete BhBpForm from Project explorerAfter deleting code above not working.If i change name of form to create to BhBpForm1 code work again and BhBpForm1 was created.
Sub cbCreateUserForm()Dim vbeditor As VBESet vbeditor = Application.VBEDim stform As VBComponentSet stform = vbeditor.ActiveVBProject.VBComponents.Add(vbext_ct_MSForm) 'work create Form with standart name UserForm1, UserForm2 etc.stform.Name = "BhBpForm1"stform.Properties("Caption") = "BhBpCaption"stform.Properties("BackColor") = vbRed
Rememmber - BhBpForm was deleted.
I try to create BhBpForm again with code above, but he retturn me error.If I restart CorelDRAW i can create BhBpForm againI think, that restarting Corel clears memory from many things.I ask for method to reset CoreDRAW with VBA code without restarting CorelGreetings!
Maybe some BYTECODE cache, but unlikely since VBA uses JIT. Just one correction, your code generates "form" in DESIGN TIME and not RUNTIME
Thank You for this answer!What is difference between DESIGN TIME and RUN TIME coding? My code generates user form. I think this is RUN TIME creating of user form. I think DESIGN TIME is when we use Visual Basic Editor for coding. Please, explain!
Yes, you can create code that generates code, this is the process that many IDEs use, including the VBA Editor, for example, when you click on insert->UserForm, a code was generated in design time, all code generated before Compilation (simplified) is design time. There are three main stages DESIGN TIME, COMPILE TIME, RUN TIME. The editor uses code to generate forms when we insert one of them, so we have visual feedback. Simply put, this is a complex subject, but it's just for clarification because if it solves your problem, that's what's important.code generated by visual studio to insert a form