I have a spreadsheet with a vbModeless UserForm that works for one business unit. When I open this spreadsheet and Save As to a different name I can close it and open it with no errors. But if I double-click on the first tab and change the tab name for another business unit then save the document; when I reopen it and enable macros I get a "Run-time error 57121" - Application-defined or object defined error.
If I click End then click on design mode, all the code for the sheets open in the VBAProject window. I can F8 to step through and everything seems to work fine until I save it and reopen it, then I get a Microsoft Encountered Problems and it wants to recover my data and restart Excel.
If I click Debug it takes me to the ThisWorkbook Workbook_Open event at the line - Call sBUxExt.UserForm_Initialize; but it won't let me proceed until I stop and click design mode, then again I can step through seemingly without a problem until I save and reopen it.
Here is the code:
Instead of the default Sheet1, etc, all are named, the first worksheet is named sBUxExt.
The UserForm has 30+ objects on it and the code is considerably longer.
Any help would be appreciated so I don't pull the rest of my hair out...
Charlie
If I click End then click on design mode, all the code for the sheets open in the VBAProject window. I can F8 to step through and everything seems to work fine until I save it and reopen it, then I get a Microsoft Encountered Problems and it wants to recover my data and restart Excel.
If I click Debug it takes me to the ThisWorkbook Workbook_Open event at the line - Call sBUxExt.UserForm_Initialize; but it won't let me proceed until I stop and click design mode, then again I can step through seemingly without a problem until I save and reopen it.
Here is the code:
Code:
'
' ThisWorkbook Object code
'
Private Sub Workbook_Open()
sBUxExt.Activate
Call sBUxExt.UserForm_Initialize
End Sub
'
' sBUxExt Object code
'
Private Sub cmdLoadForm_Click()
Call UserForm_Initialize
End Sub
Public Sub UserForm_Initialize()
'
' Initialize UserForm with the values saved on sBUxExt Worksheet
'
UserForm1.optOpenPortsHide = sBUxExt.optHidePorts.Value
UserForm1.optOpenPortsShow = sBUxExt.optShowPorts.Value
UserForm1.chkColB = sBUxExt.chkColB.Value
UserForm1.chkColC.Value = sBUxExt.chkColC.Value
UserForm1.chkColD.Value = sBUxExt.chkColD.Value
UserForm1.chkColE.Value = sBUxExt.chkColE.Value
UserForm1.chkColF.Value = sBUxExt.chkColF.Value
UserForm1.chkColG.Value = sBUxExt.chkColG.Value
UserForm1.chkColH.Value = sBUxExt.chkColH.Value
UserForm1.chkColI.Value = sBUxExt.chkColI.Value
UserForm1.chkSheet1.Value = sBUxExt.chkPrint1.Value
UserForm1.chkSheet2.Value = sBUxExt.chkPrint2.Value
UserForm1.chkSheet3.Value = sBUxExt.chkPrint3.Value
UserForm1.chkSheet4.Value = sBUxExt.chkPrint4.Value
UserForm1.chkSheet5.Value = sBUxExt.chkPrint5.Value
UserForm1.chkSheet6.Value = sBUxExt.chkPrint6.Value
UserForm1.chkSheet7.Value = sBUxExt.chkPrint7.Value
UserForm1.chkSheet8.Value = sBUxExt.chkPrint8.Value
UserForm1.txtSheet1.Value = sBUxExt.Range("P15").Value
UserForm1.txtSheet2.Value = sBUxExt.Range("P16").Value
UserForm1.txtSheet3.Value = sBUxExt.Range("P17").Value
UserForm1.txtSheet4.Value = sBUxExt.Range("P18").Value
UserForm1.txtSheet5.Value = sBUxExt.Range("P19").Value
UserForm1.txtSheet6.Value = sBUxExt.Range("P20").Value
UserForm1.txtSheet7.Value = sBUxExt.Range("P21").Value
UserForm1.txtSheet8.Value = sBUxExt.Range("P22").Value
UserForm1.txtInfo.Value = sBUxExt.Range("P24").Value
' Set the window values
sBUxExt.Activate
With ActiveWindow.VisibleRange
UserForm1.Top = sBUxExt.cmdLoadForm.Top
UserForm1.Left = sBUxExt.cmdLoadForm.Left
End With
' Now load the userform
Load UserForm1
UserForm1.Show (modeless)
End Sub
Instead of the default Sheet1, etc, all are named, the first worksheet is named sBUxExt.
The UserForm has 30+ objects on it and the code is considerably longer.
Any help would be appreciated so I don't pull the rest of my hair out...
Charlie