Displaying Userform Crashes Excel ONLY if it is the First Action After Opening the Workbook

tsgnms

New Member
Joined
Jun 29, 2016
Messages
14
Office Version
  1. 365
Platform
  1. Windows
I have a userform called "ProductDBForm" that uses a multipage to provide detailed data on all products in our range. I use a "Homepage" of sorts with a few images and a transparent box over each with a macro assigned to launch the relevant form or function. One of these is used to launch the "Product Database" using the following code:

VBA Code:
Sub launchProdDB()

    If UserCheck(12) = "NO" Then
        MsgBox "Sorry, you do not have the required permissions to access this function.", vbCritical + vbOKOnly, "Access Denied"
        Call saveLog("PrDB Access Denied.", "User attempted to launc the product database; permissions not found")
        Exit Sub
    End If
        
    
Sheets("ProductDB").Visible = True
Sheets("ProductDB").Select
    
    With ProductDBForm
        .StartUpPosition = 1
        .Show vbModeless
    End With
    
   Call saveLog("Open PrDB", "User successfully launched product database")

End Sub

The code has worked flawlessly since I added it until yesterday when, for reasons I'm yet to understand, it started crashing Excel when run via the homepage click. However it only crashed Excel if clicking the image that runs this macros is the first thing a user does when opening the workbook.

I can still launch the form the following ways:
1. If I enter the VBA editor and open the userform edit page, I can display it perfectly by hitting the F5 key
2. If I enter the VBA editor and run the "launchProdDB" code, it displays the form perfectly
3. If I run another piece of code before running the "launchProdDB" code, I can then run the "launchProdDB" code and it works perfectly

Once any of the above are done, I can then click the image on my "homepage" to run the "launchProdDB" code above without any issues.

The code only crashes if it is the very first thing a user does when opening the workbook. I know that all the code works because I can run it without making any changes to it as long as it isn't the first thing I do.

Does anyone have any suggestions or ideas on what might be causing this all of a sudden, and why it works fine the rest of the time?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Sorry - I should have also mentioned that the two functions (saveLog() and CheckUser()) work perfectly in all other codes and I'm confident they are not the source of the problem. I tried removing both functions from the launchProdDB code but it still crashes when run after opening.

Furthermore, the only error code I seem to find from Excel is "BEX"
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,179
Members
448,871
Latest member
hengshankouniuniu

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