Damaged userform

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
893
I have a userform that seems to be corrupted. When opening within the vb editor it creates a message saying "Access error opening path or file". The userform works well when "called" within the Excel environment (outside vba editor)

It is an essential but also complicated userform; one that I can not recreate quickly. I really need to mke some adjustments in the code. Is there a way to "repair" the userform so it can be edited again?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I retry to define my question.

I go to the vb editor and select in the forms section the requested userform for editing. I do have access to the code (right mouse click; show program code). I do not have access to the form itself (right mouse click; show object). I get an error message saying: “Path/File access error”. Help gives additional information; saying it is an error 75 but also that this can be caused by several reasons. None of them seems to be relevant.

The funny thing is that the userform ran within Excel does what it should do (it shows a pic according to the full path name in the active cell)

The code within the form is as follows:

Private Sub CommandButton1_Click()
ActiveCell.Offset(1, 0).Select
WindowsMediaPlayer1.URL = ActiveCell.Text
TextBox1 = ActiveCell.Value
SoundPlayer.TextBox1.SetFocus
End Sub

Private Sub CommandButton2_Click()
ActiveCell.Offset(-1, 0).Select
WindowsMediaPlayer1.URL = ActiveCell.Text
TextBox1 = ActiveCell.Value
SoundPlayer.TextBox1.SetFocus
End Sub

Private Sub CommandButton3_Click()
WindowsMediaPlayer1.Close
ActiveCell.Value = TextBox1
SoundPlayer.TextBox1.SetFocus
Application.Run "Rename_file"
End Sub

Private Sub CommandButton4_Click()
End
End Sub

Private Sub Label1_Click()

End Sub

Private Sub UserForm_Activate()
Label1 = ActiveCell.Value
TextBox1 = ActiveCell.Value
WindowsMediaPlayer1.URL = ActiveCell.Text
SoundPlayer.CommandButton2.SetFocus
SoundPlayer.TextBox1.SetFocus
End Sub

Any suggestions how to overcome the problem?
 
Upvote 0
Hi, Will,
(still playing with media ?)
can you export the userform ?
then you can drag UserForm1.frm into notepad and see your code again
from there you could recreate your form (or edit the code)

because it seems to be corrupted, I would delete it and create it again
OR
copy the userform from a previous version and paste again your more recent code

does this help?
best regards,
Erik
 
Upvote 0
Erik

Yep, actually got it down from the attic and wanted to bring in some adjustments.

Nope, can not export it. Could scavenge the attic further if there is indeed an older version still around. If I remember well the userform got corrupted a few times (recreated the form a few times before) but still do not knwo what the actual reason is...

Erik, thanks for your reply.
 
Upvote 0
but still do not knwo what the actual reason is
just an idea...
change activate_event to "initialize"event
or quote out that part for a while and feed the userform with an extra button
Private Sub extra_button_click()
Label1 = ActiveCell.Value
....
End Sub
 
Upvote 0
Erik

I did add your changes. The userform still works within Excel but the userform can not be opened to be edited.

The good thing is that these adjustments make that I can save the file again (got error messages here; the file is not saved).

I adjusted the code like this:

Private Sub CommandButton1_Click()
ActiveCell.Offset(1, 0).Select
WindowsMediaPlayer1.URL = ActiveCell.Text
TextBox1 = ActiveCell.Value
SoundPlayer.TextBox1.SetFocus
End Sub

Private Sub CommandButton2_Click()
ActiveCell.Offset(-1, 0).Select
WindowsMediaPlayer1.URL = ActiveCell.Text
TextBox1 = ActiveCell.Value
SoundPlayer.TextBox1.SetFocus
End Sub

Private Sub CommandButton3_Click()
WindowsMediaPlayer1.Close
ActiveCell.Value = TextBox1
SoundPlayer.TextBox1.SetFocus
Application.Run "Rename_file"
End Sub

Private Sub CommandButton4_Click()
End
End Sub

Private Sub Label1_Click()

End Sub

Private Sub UserForm_initialize()
Label1 = ActiveCell.Value
TextBox1 = ActiveCell.Value
WindowsMediaPlayer1.URL = ActiveCell.Text
SoundPlayer.CommandButton2.SetFocus
SoundPlayer.TextBox1.SetFocus
End Sub

Private Sub extra_button_click()
Label1 = ActiveCell.Value
TextBox1 = ActiveCell.Value
WindowsMediaPlayer1.URL = ActiveCell.Text
SoundPlayer.CommandButton2.SetFocus
SoundPlayer.TextBox1.SetFocus

End Sub
 
Upvote 0
Hi, Will,
the extra_button_click was meant to replace the UserForm_initialize() temporarely
you don't need both at the same time
the purpose was to avoid some bugs: since ou save again, you've got a little step forwards

I wouldn't waste time trying to get the form back
anyway it is corrupt
you must have edited it much, creating and deleting buttons and other controls ...

create the form without code
if you accidently create a control, immediately UNDO (Ctrl+Z), never delete it: this is to my sense the cleanest way of proceeding
I learned today that pasting code to NotePad, then deleting the modules and then pasting from the textfile in new modules could help to cure corrupted workbooks

these are my latest ideas
sleeping :)
Erik
 
Upvote 0
I guess I will follow your suggestion to re-construct the userform. thanks for your suggestions. :p
 
Upvote 0
TIP:
save it in different "development-states"
(I would create a newworkbook as userform-backup and drag the userform each time to there using significative name)
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

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