Run-time error 57121 on specific machines only

jpjosey

New Member
Joined
Mar 7, 2017
Messages
6
I've had some issues lately where upon emailing a file it loses some functionality, but only for me...

Prime example:

I have a file that was working for me, on 64b 2013, I sent it to other people with 32b 2010 and 32b 2013, and it works fine for them.

However it has at some point stopped working for me on both my 64b 2013 and 32b 2010 machines. Despite the exact same file still working for other people.

An example of the error is...

Code:
Function SheetExists(sSheet) As Boolean


SheetExists = False
For Each ws In ActiveWorkbook.Worksheets
    If sSheet = ws.Name Then
        SheetExists = True
        Exit Function
    End If
Next ws


End Function

I can see in the locals window at the error point that sSheet = "Report" and ws.Name = "AdminOnly" -- however it errors on the line;

Code:
 If sSheet = ws.Name Then

With the error message;
Code:
Run-time error '57121':  Application-defined or object-defined error.

I have enabled both macros and activex controls completely. I tried a the office repair tool. I rolled back to a system restore from when it was working. I reinstalled office. I did a fresh install of windows with a clean office install. Problem persists.

At the rate I'm pulling my hair out I'm going to be bald by the end of the week.

What am I missing here? Why can my colleagues run the macros but I cannot?
 

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.
If you have ActiveX controls on your worksheets, I suspect they are the cause: Office Update breaks ActiveX controls | Excel Matters
Note that there have been several occasions where this kind of thing has happened with an Office update. If at all possible, I'd suggest you switch to Form controls as they are much more stable and not prone to this issue.
 
Upvote 0
Have you tried setting the value to string instead of a variant?:

Code:
[COLOR=#333333]Function SheetExists(sSheet [/COLOR][COLOR=#ff0000][B]as String[/B][/COLOR][COLOR=#333333]) As Boolean[/COLOR]

Edit: Ahh just saw the first reply. Didn't think of those. I use Active X with no issues (thankfully) though after reading that I may have to change them for future compatibility :eek:
 
Last edited:
Upvote 0
Interesting.

I added

Code:
dim ws as Worksheet

and it doesn't bug there, but does bug out with the same error here;
Code:
 sMailTo = Worksheets("AdminOnly").Cells(2, 5).Value

Despite having just pulled various other values from OTHER sheets in exactly the same way. There's something about this AdminOnly sheet that's screwing things up and I can't put my finger on it.
 
Upvote 0
I'd make sure each variable is explicitly declared. have you got a
Code:
Dim sMailTo as String
line?
 
Upvote 0
I replaced

Code:
sMailTo = Worksheets("AdminOnly").Cells(2, 5).Value

with

HTML:
Dim ws_admin As WorksheetSet ws_admin = Worksheets("AdminOnly")sMailTo = ws_admin.Cells(2, 5).Value

and it works fine now! What on earth?!</div>
 
Upvote 0
I'd make sure each variable is explicitly declared. have you got a
Code:
Dim sMailTo as String
line?

Yeah that didn't work...

But the above did.

Why all of a sudden does it require explicits only for a specific tab on specific machines? I don't mind being explicit, but functionality shouldn't just stop working for no apparent reason. >.<
 
Upvote 0
I replaced

Code:
sMailTo = Worksheets("AdminOnly").Cells(2, 5).Value

with

Code:
Dim ws_admin As WorksheetSet ws_admin = Worksheets("AdminOnly")sMailTo = ws_admin.Cells(2, 5).Value

and it works fine now! What on earth?!

Sorry, fixed the code tag -- couldn't find the edit button
 
Upvote 0
I replaced

Code:
sMailTo = Worksheets("AdminOnly").Cells(2, 5).Value

with

Code:
Dim ws_admin As WorksheetSet
 ws_admin = Worksheets("AdminOnly")
sMailTo = ws_admin.Cells(2, 5).Value

and it works fine now! What on earth?!

ugh
 
Upvote 0
With the ActiveX problems I mentioned, I've seen compile errors on a module that had nothing other than Option Explicit in it. As soon as the ActiveX controls were removed, the errors went away.
 
Upvote 0

Forum statistics

Threads
1,212,927
Messages
6,110,700
Members
448,293
Latest member
jin kazuya

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