Solved

MS Publisher "The Clipboard is Busy"

Posted on 2009-04-14
5
1,998 Views
Last Modified: 2013-12-02
Error:
MS Publisher reports error -2147221040
The clipboard is busy, MS Publisher can not copy, cut, paste because another program is using the clipboard

Problem:
I've written a macro that copies a range of shapes from one document to another in order to simulate copying a page between documents.  When this macro runs in a loop (10 - 15 iterations), I frequently receive the error cited above.  I can run the macro, receive the error, and when I click OK on the error dialog, the macro continues and copies subsequent pages.

Often, after deleting the pages and re-running the macro, it will run perfectly.   Note that the shapes being copied include an image (800 x 600 jpg).

Environment:
Vista, Publisher 2007

When I run the macro, three publisher documents are open, but no other programs are loaded.
0
Comment
Question by:man-on-a-mission
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:Gregg DesElms
ID: 24144810
I may be taking a shortcut, here, but without looking-up the error and really applying proper troubleshooting techniques, just from the seat of my pants, it sounds -- untechnical an inelegant as the phrase is -- like things are getting kinda' all stacked-up... like that clipboard needs to pause for a second the first time around -- right around the 15th iteration -- so it can grab a bit more RAM for itself, and during that pause, the error kicks.  Then you dismiss it and it finishes.  Then you run it again and since the clipboard is already, on second and successive runs, as big as it needs to be, it flies through it all without a hitch.

Sounds like some pauses (not the kind which must be manually dismissed or which require a keystroke to cause continuation but, rather, the kind that are timed) inserted into your macro in just the right places.

It smacks of a VB automation error, to be honest... which makes sense, since VB is an integral part of Office 2007's macro capability.  I confess that I'm hoping my seat-of-the-pants logic, and my suggested solution, is enough to take you home so I don't have to go look it all up and get all technical about it. [grin]
0
 

Author Comment

by:man-on-a-mission
ID: 24150367
That was my initial hunch as well, so I did 1 second delay after each page was copied.  I tried the Sleep procedure, and I tried the OnTime method shown below.  I couldn't get Sleep to work for some reason, and the OnTime seemed to be a little worse.

However, I found that if I ran the macro from a third document (neither the source, or the destination documents) I do not receive the error.   This is OK in my case, for this particular project, but it would still be nice to resolve the problem in order to generalize the code for reliable reuse.

'DELAY TACTIC #1
Declare Sub Sleep Lib "kernel32" Alias "Sleep"  (ByVal dwMilliseconds As Long)
 
Sub Sleep()
   Sleep 1000 
End Sub
 
'DELAY TACTIC #2 
 Sub MyMainMacro()
   Application.OnTime When:=Now + TimeValue("00:00:1"),  Name:="PostSleep"
End Sub
 
Public Sub PostSleep()
 ' do nothing after sleep
End Sub

Open in new window

0
 
LVL 5

Accepted Solution

by:
Gregg DesElms earned 250 total points
ID: 24176371
Sorry it took so long to get back to you... I got a little swamped for a few days.

I'm not as up as I should be on the code you're trying in order to help you to the degree that you need to be helped.  I mean I could be, if I could find the time, but I can't.  So if we can stay with generalizations, I might at least be able to spark some notion in you which could get you there...

...and the question I have which may do just that is this:  After you've pasted something, is there any way to verify, using code, that said pasting succeeded before moving onto the next copy-and-paste?

If so, then that would be better than timers.  With timers, you're just guessing... operating in the blind... hoping the end-user's machine on which the code may run will be as fast as yours, or have as much RAM (or have a little in it)... that sort of thing.  But when you can perform a task with code, then verify that it happened before moving on to the next task (and have a plan "B" piece of code if the verification fails), then it doesn't matter how fast the code runs, or well the machine is able to keep up with whatever are the tasks.

Thoughts?
0
 

Author Comment

by:man-on-a-mission
ID: 24176718
I'll look into that.  Thanks for the tickler.
0
 

Author Closing Comment

by:man-on-a-mission
ID: 31570068
I'm not quite sure how to close this, but this seems about right.  Since I can work around the problem, that's what I'm going to do.  Though I couldn't find any information regarding handling the paste status, clearly there is an error and at some point I will probably go back and trouble-shoot with some error handling.  For now I have to move on.  Thanks.
0

Featured Post

RoboForm Secure Password Management System

RoboForm Everywhere - Superb Browser Support
Windows / Apple / IOS / Android / Linux / Chrome OS
Use different complex passwords everywhere
Best Secure Password Management by far
Synchronize all of your devices instantly
Safe, Secure & Highly Recommended!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question