Need help with "Error in Activate/Deactivate Procedure"

theanchorman

New Member
Joined
Aug 24, 2012
Messages
31
Hello,

This is the first time where I got an error that I cannot find anything online about. I don't know when this issue occurs but sometimes randomly I get messages "Error in Activate Procedure" or "Error in Deactivate Procedure". Can anyone help me on this?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
i googled "Error in Activate Procedure excel" and there is nothing. I don't think that is an excel error message. Excel won't have random errors unless your install is corrupted or something and in that case you just reinstall. I have no idea what your error is since there is no documentation about it online. You may want to double check what the error message says and if it is indeed excel displaying the message and not some random process running on your pc.
 
Upvote 0
It usually happens when I am switching between excel files, and it does say Microsoft Excel on the top when the message comes up. Wish I knew how to attach an image from my desktop. I wonder if it could be macro related, but I'm not running anything?
 
Upvote 0
Just press Print screen, then it will copy your screen to the clipboard, then paste it in the ms paint program. Then upload that image to Imgur or any image hosting site. Then use the insert image button when replying here and give the imgur link.

if you do it right, it will look like this...

ShAz2X7.png


imgur links look like this... https://i.imgur.com/ShAz2X7.png (i cropped the image in ms paint)
 
Last edited:
Upvote 0
I just had a thought... do you have a macro enabled workbook open, with code inserted into the activate and deactivate events?

it sounds like excel is having a problem calling workbook events... not sure why... it sounds like something is corrupted.
 
Upvote 0
I just had a thought... do you have a macro enabled workbook open, with code inserted into the activate and deactivate events?

it sounds like excel is having a problem calling workbook events... not sure why... it sounds like something is corrupted.

I dont think so, and this doesnt happen everytime when I open the file. I'll have to run through all the macros.
 
Upvote 0
Yeah double check every sheet object and workbook object in the vba editor for every project listed and make sure no event code is being used. So you need to open the files that are causing the problems and these files will be listed as projects in the vba editor.

So Excel is programmed to call an activate and deactivate event when the workbook is focused/unfocused (i might be wrong, google "excel workbook activate" event) and it sounds like the error has to do with these events being called. The only way there can be a problem is if you wrote some code to be called in these events and this code is conflicting with each other.
 
Upvote 0
Okay so I found the code in the VBA editor that was causing this issue, but I dont understand what the code is trying to say?

Public bClose As Boolean


Private Sub Workbook_Activate()
On Error GoTo proc_error
Application.CommandBars("View/Print").Visible = True
proc_end:
Exit Sub
proc_error:
MsgBox "Error in Activate Procedure"
Resume proc_end
End Sub


Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error GoTo proc_error
bClose = True
proc_end:
Exit Sub
proc_error:
MsgBox "Error in BeforeClose Procedure"
Resume proc_end
End Sub


Private Sub Workbook_Deactivate()
On Error GoTo proc_error
Application.CommandBars("View/Print").Visible = False
'This deletes from the collection but not permanently
If bClose = True Then Application.CommandBars("View/Print").Delete
proc_end:
Exit Sub
proc_error:
MsgBox "Error in Deactivate Procedure"
Resume proc_end
End Sub


Private Sub Workbook_Open()
On Error GoTo proc_error
Application.CommandBars("View/Print").Position = msoBarTop
proc_end:
Exit Sub
proc_error:
MsgBox "Error in Open Procedure"
Resume proc_end
End Sub
 
Upvote 0
As far as I can see it's trying to show/hide a command bar named 'View/Print' which I'm not sure is a standard command bar so might be something that somebody has created specially for this workbook.

If you delete all the posted code does the workbook open without error?

If it does is there any functionality missing?
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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