Link to home
Start Free TrialLog in
Avatar of mfeldman
mfeldman

asked on

Cut and Paste in MAPPOINT

I am controlling Microsoft Mappoint and Powerpoint from VBA in Excel.  The program opens mappoint, does a dataset copy and then pastes it into powerpoint (to get the legend).

This works most of the time.  However, about 5% of the time, randomly, the copy operation fails and the subsequent paste operation actually pastes the previous contents of the clipboard.  It never fails in the same place and most of the time it doesn't fail at all.

This leads me to speculate that the copy operation, in mappoint,  is being performed asynchronously and thus my program gets control and initiates the paste before it completes.

Does anybody have a solution for this?  Is there anyway I can test the clipboard to see whether or not an operation is completed?   I've tried adding delays in the program and loops with doevents, but that seems to make the problem worse.

Help!


ASKER CERTIFIED SOLUTION
Avatar of srikanth_a
srikanth_a

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mfeldman
mfeldman

ASKER

How do I check the clipboard size?  And is there a way for me to empty the clipboard (in VBA) prior to the cut/paste operation so I can make sure I have enough space?

Thanks for the help,

Mike
Thanks, but it doesn't seem to work.
In Excel, here's the code I tried for the test:

Declare Function EmptyClipboard Lib "user32" () As Long
Sub x()
    Range("A1").Copy
    z = EmptyClipboard()
    Range("B1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
End Sub

The paste worked despite the emptyclipboard.  There was no error message, so I'm not quite sure what happened.

-Mike
It turns out that I really didn't have to completely empty the clipboard.  I simply put a
range("a1").copy
in the code which copied a null cell to the clipboard.  

This seems to have cured the problem, although since it was a somewhat random problem I want to test it a bit more.  But unless something turns up, I'll accept Srikanth's answwer.

-Mike