Excel VBA - Run Time Error

Skyybot

Well-known Member
Joined
Feb 18, 2023
Messages
1,229
Office Version
  1. 365
Platform
  1. 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
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
It works for me if in each macro I add at the end

ThisWorkbook.Save
 
Upvote 0
Solution

Forum statistics

Threads
1,224,813
Messages
6,181,114
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top