Pasting after Workbook Activate event

  • Thread starter Michael Malinsky
  • 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.
 
B

Bob Umlas

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top