Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old November 12th 20, 03:33 AM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Mar 2020
Posts: 37
Default UserForm triggers File Corruption

Hi Team

The file works perfectly. If I initialize the form internally, it works as expected, but! If I initialize it via:

[ThisWorkbook]
Private Sub Workbook_Open()

A Popup displays citing "Excel has stopped working" and reboots whereby it tries to repair the file, ultimately rendering it useless.

I have tried several times without success. Any assistance is appreciated.
TIA
Mark.

.................................................. .................................................. .........................

I have a UserForm "frmLogin". It is very basic with the following:

1 x Combo = "cmb_uName"
RowSource = uTable
ControlSource = Admin!B5

1 x TextBox = "txf_uPass"
ControlSource = Admin!B6

1 x cmdBtn = "cmd_OK"

There is no Initialize code, only the following:

Private Sub cmb_uName_Change()
Me.txf_uPass.SetFocus

End Sub
Private Sub cmdBtn_OK_Click()
CheckUser
End Sub

CheckUser has the following:

Sub CheckUser()

Dim sAdmin As Worksheet: Set sAdmin = ThisWorkbook.Sheets("Admin")
Dim obj As OLEObject
Dim uRow, sCol As Long
Dim sName, dSht As String

With sAdmin
.Calculate
If .Range("B8").Value = Empty Then
MsgBox "Only Registered Users are listed, Please contact [Alan Gotts] for Registration."
Exit Sub
End If
If .Range("B7").Value < True Then
MsgBox "Incorrect Password entered! Please try again."
Exit Sub
End If

Unload frmLogin

uRow = .Range("B8").Value
dSht = "Dashboard"

For sCol = 8 To 20
sName = .Cells(2, sCol).Value
If .Cells(uRow, sCol).Value = "Ð" Then
With Sheets(sName)
.Unprotect "TooBadSoSad"
.Visible = xlSheetVisible
End With
With Worksheets(dSht)
For Each obj In .OLEObjects
Select Case obj.Name
Case "cmdBtn_Import"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Goto_Register"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_goto_Status"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Goto_Bulk"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Goto_PAG"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Goto_NSW"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Goto_QLD"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Goto_SA"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Goto_VIC"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Goto_BKPI"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Goto_PKPI"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_View_BKPI"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_View_PKPI"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Print_BKPI"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Print_PKPI"
.OLEObjects(obj.Name).Enabled = True
End Select
Next
End With
End If
If .Cells(uRow, sCol).Value = "Ï" Then
With Sheets(sName)
.Protect "TooBadSoSad"
.Visible = xlSheetVisible
End With
With Worksheets(dSht)
For Each obj In .OLEObjects
Select Case obj.Name
Case "cmdBtn_Import"
.OLEObjects(obj.Name).Enabled = False
Case "cmdBtn_Goto_Register"
.OLEObjects(obj.Name).Enabled = False
Case "cmdBtn_goto_Status"
.OLEObjects(obj.Name).Enabled = False
Case "cmdBtn_Goto_Bulk"
.OLEObjects(obj.Name).Enabled = False
Case "cmdBtn_Goto_PAG"
.OLEObjects(obj.Name).Enabled = False
Case "cmdBtn_Goto_NSW"
.OLEObjects(obj.Name).Enabled = False
Case "cmdBtn_Goto_QLD"
.OLEObjects(obj.Name).Enabled = False
Case "cmdBtn_Goto_SA"
.OLEObjects(obj.Name).Enabled = False
Case "cmdBtn_Goto_VIC"
.OLEObjects(obj.Name).Enabled = False
Case "cmdBtn_Goto_BKPI"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Goto_PKPI"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_View_BKPI"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_View_PKPI"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Print_BKPI"
.OLEObjects(obj.Name).Enabled = True
Case "cmdBtn_Print_PKPI"
.OLEObjects(obj.Name).Enabled = True
End Select
Next
End With
End If
If .Cells(uRow, sCol).Value = "x" Then
With Sheets(sName)
.Visible = xlSheetVeryHidden
End With
End If
Next sCol
End With

End Sub

  #2   Report Post  
Old November 12th 20, 05:13 AM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Mar 2020
Posts: 37
Default UserForm triggers File Corruption

Hi All

Rather than get an brain-aneurysm, if created a whole new UserForm and deleted the original.

Working as expected and without incident now. No idea why the original UserForm was having such a Hissy-fit.

Cheers and thanks.
Mark.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Suspected corruption in file YvonneW Excel Discussion (Misc queries) 1 April 15th 09 12:23 AM
Check Excel file for Corruption? dwillman Excel Discussion (Misc queries) 2 February 27th 09 05:58 PM
Excel 2007 File corruption DanC Excel Discussion (Misc queries) 0 August 12th 08 07:19 PM
EXCEL file corruption Dean[_8_] Excel Programming 8 April 15th 06 04:54 AM
opening text file triggers vb error Elie[_2_] Excel Programming 2 November 26th 03 12:36 PM


All times are GMT +1. The time now is 09:54 PM.

Powered by vBulletin® Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright 2004-2020 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"

 

Copyright © 2017