Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
711 views
in Technique[技术] by (71.8m points)

vba - What is causing "Automation error Unspecified error" on Worksheet_Activate?

I have a worksheet named "Dates" (object name is A_Dates) that needs to be calculated when it is activated (It may be worth noting that this is in my Personal macro workbook). I regularly have workbooks open that have too many calculations in the for me to have auto-calculation on. So I have auto-calc set to manual, and the following code in the worksheet:

Private Sub Worksheet_Activate()
   A_Dates.Calculate
End Sub

This has worked fine for the last 3 months, day-in and day-out. Yesterday, it stopped working. It now throws this error on the declaration line:

Microsoft Visual Basic
Automation error
Unspecified error
[OK] [Help]

I have tried changing how I reference the sheet, using:

Sheets("Dates").Calculate

and

ActiveSheet.Calculate

to no avail. I've also included error handling:

On Error Resume Next

which doesn't prevent it. I've even gone so far as:

Private Sub Worksheet_Activate()
   On Error GoTo headache
   Sheets("Dates").Calculate
Exit Sub

headache:
   Exit Sub
End Sub

and it still shows up. I am totally at a loss. Help?

Additional Information

I have the following references, and use all of them in various macros in this workbook:

Visual Basic for Applications

  • Microsoft Excel 12.0 Object Library
  • OLE Automation
  • Microsoft Office 12.0 Object Library
  • Microsoft Scripting Runtime
  • Microsoft Forms 2.0 Object Runtime
  • Microsoft HTML Object Library
  • Microsoft Internet Controls
  • Microsoft ActiveX Data Objects 2.8 Library
  • Microsoft ActiveX Data Objects Recordset 2.8 Library
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

We ran into the same problem, but with a twist - we have several people all using the same macros successfully, but one is having the "Automation Error" "Unspecified Error" problem. The other answer helped me identify that the problem might be due to the "Microsoft ProgressBar Control". (Thank you very much)

But instead of removing the form, I unregistered and registered the MSCOMCTL.OCX on the user's PC that was having problems and he's back in business again. I wish I knew what caused the registration of the control to go south - this is not the first time I've had to track down problems with this control.

To unregister and register the control:

Use an “Elevated command prompt” (command prompt run as an administrator), issue the following commands:

 Regsvr32 /u c:windowsSysWOW64MSCOMCTL.OCX

 Regsvr32 c:windowsSysWOW64MSCOMCTL.OCX

NOTE: the /u unregisters the ocx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...