Skyybot
Well-known Member
- Joined
- Feb 18, 2023
- Messages
- 1,110
- Office Version
- 365
- Platform
- Windows
Hi, All. I have, in ThisWorkbook code module, a piece of code to create a VBA UserForm component. After first opening the file, the routine runs with no problems. I also have a piece of code to remove all UserForm VBA components (which always runs with no problem). After I run this subroutine and try to run the first subroutine I get "Run-time error '75': Path/File access error. While it still creates the UserForm component, it won't name it. If I close the file and re-open it, no problem on the first run. Does anyone know how I can fix this issue?
VBA Code:
Option Explicit
Sub MakeBlankForm()
Dim frm As VBComponent
Set frm = Me.VBProject.VBComponents.Add(vbext_ct_MSForm)
With frm
.Name = "BlankForm"
End With
End Sub
VBA Code:
Sub RemoveForms()
Dim frm
For Each frm In Me.VBProject.VBComponents
If frm.DesignerID = "Forms.Form" Then
Me.VBProject.VBComponents.Remove frm
End If
Next frm
End Sub