Run Tim Error 429 - Active x component can't create an object

2022

Board Regular
Joined
Jun 5, 2022
Messages
74
Office Version
  1. 2016
Platform
  1. Windows
Hi, I'm getting an error that says 'Run Tim Error 429 - Active x component can't create an object' when I switch tabs in a worksheet.

The tab I'm on is called "Page 1" but when I click out of that tab, then go back to it, I get the run time error and the code stops at the line that says "Set wb = ThisWorkbook"

I've pasted a sample of the code below - does anyone know why this would happen?

VBA Code:
Option Explicit

Private Sub Worksheet_Activate2()

Dim wb As Workbook
Dim sh As Worksheet

Dim sh2 As Worksheet


Set wb = ThisWorkbook
Set sh = wb.Sheets("Page 1")

End Sub
 

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)
Unless you are calling it from somewhere else, that code will not run when you switch sheets since it's called Worksheet_Activate2 not Worksheet_Activate
 
Upvote 0
Thanks for the quick response, @RoryA

I copied the code up to that line that produces an error.

Then renamed the Sub by putting the number '2' at the end, to avoid having two subs with the same name within the same worbook.

But you're correct in pointing out that the Sub should be called 'Private Sub Worksheet_Activate()' rather than 'Private Sub Worksheet_Activate2()'

Do you know of any other reason why the code wouldn't run when moving away from the "Page 1" worksheet to another tab, then going back to "Page 1"?

Thanks in advance.

VBA Code:
Private Sub Worksheet_Activate()

Dim wb As Workbook
Dim sh As Worksheet

Dim sh2 As Worksheet

Set wb = ThisWorkbook
Set sh = wb.Sheets("Page 1")
 
Upvote 0
The code itself looks fine, and certainly shouldn't cause that error. If it is in fact that code that is causing the error (and as I mentioned, that code shouldn't have run at all as it was), then you may have a corrupt workbook.
 
Upvote 0
Ok, thank you for your thoughts.

When I closed the workbook and re-opened it, then tested it again, it started working without again without the issues. But if the issue recurs, I'll reach out and let you know if I notice anything specific.

Thanks and I hope you have a Merry Christmas!
 
Upvote 0
Thank you and merry Christmas to you too! :)
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,544
Members
452,925
Latest member
duyvmex

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