Pasting after Workbook Activate event

  • Thread starter Thread starter Michael Malinsky
  • Start date Start date
M

Michael Malinsky

I have some VBA code that makes a menu item on the standard menu bar
appear/disappear based on whether a certain workbook (MyWorkbook) is
the active workbook. Some of this code is located in the ThisWorkbook
object which then calls other procedures located in Module1. For those
of you that may be familiar, I'm using the code crated by Byg Software.

My question is this. If I am trying to copy/paste something to/from
MyWorkbook, the Workbook Activate event clears the clipboard which
pretty much (well, completely) kills the procedure.

Is there any way around this?

Thanks,
Mike.
 
set some variable to the range you want to copy, like
Set MyVariable = Range("RangeToCopy")
then IN the workbook.Activate, before pasting, copy (again, maybe) by
MyVariable.Copy
THEN paste.

Bob Umlas
Excel MVP
 
You need to temporarily disable the events to keep the events from firing,
something like this (an error handler is advised with this type of code)...

sub YourSub()
on error goto ErrorHandler
application.enableevents = false
'your code here (no events will be firing)

ErrorHandler:
application.enableevents = true 'events are back on
end sub
 
Back
Top