Damaged userform

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
882
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?
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
882
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?
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
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
 

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
882
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.
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832

ADVERTISEMENT

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
 

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
882
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
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832

ADVERTISEMENT

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
 

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
882
I guess I will follow your suggestion to re-construct the userform. thanks for your suggestions. :p
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
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)
 

Watch MrExcel Video

Forum statistics

Threads
1,118,462
Messages
5,572,260
Members
412,451
Latest member
newbie22922792
Top