Solved

MS Publisher "The Clipboard is Busy"

Posted on 2009-04-14
5
1,862 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
My experience with Windows 10 over a one year period and suggestions for smooth operation
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now