Hi,
The aim was to have VBA create a new form upon request, rename it for ease of use in other code, collect data etc then delete it after to keep things clean.
Issue, although the occurrence if it happening are slim, is when the request is done twice and the code tries to rename the form with the same name. I get a "Path/File access error".
I'm guessing it's an excel issue with how it handles objects and names.
Although I'm now planning on adding a check to see if the form is there in the first place and only delete it on file close I would still be curious if there is anything that could be done and why it's happening?
The aim was to have VBA create a new form upon request, rename it for ease of use in other code, collect data etc then delete it after to keep things clean.
Issue, although the occurrence if it happening are slim, is when the request is done twice and the code tries to rename the form with the same name. I get a "Path/File access error".
I'm guessing it's an excel issue with how it handles objects and names.
Code:
Sub create_get_mth_form()
Dim frm As Object
Set frm = ThisWorkbook.VBProject.VBComponents.Add(3)
Debug.Print frm.Name
frm.Name = "Get_Mth2"
End Sub
Although I'm now planning on adding a check to see if the form is there in the first place and only delete it on file close I would still be curious if there is anything that could be done and why it's happening?