Results 1 to 2 of 2
  1. #1
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    San Jose, California, USA
    Thanked 0 Times in 0 Posts

    Clipboard Paste fails (Excel 2002)

    A user of my Excel tools just notified me that he couldn't paste some rows of data from my Excel file to another workbook. He can copy the data just fine (the marching ants appear around the data), but when he goes to paste it to another workbook, there is nothing to paste - the clipboard is empty. <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    I tracked this error down to code I had in the Thisworkbook events for Active/Deactivate. I used this code to restore the calculation mode that was used when Excel was launched. I then force it to auto when my tool is active. For some weird reason, this also forces Excel to dump the clipboard. Here's the code:
    <pre>Private Sub Workbook_Deactivate()
    On Error Resume Next
    Application.Calculation = OrigCalcState
    End Sub

    Private Sub Workbook_Activate()
    If OrigCalcState = 0 Then Exit Sub
    Application.Calculation = xlCalculationAutomatic
    End Sub</pre>

    The variable OrigCalcState is defined as Long and initialized at Workbook_Open.

    I fixed the problem by removing this code, but I shouldn't have to do that. I want to make sure the Calculation mode is correct but I also want the users to be able to copy/paste. Any ideas on workarounds? I haven't tested this in Excel 97 or Excel 2000 (which I have on my work PC, but not on the PC I'm using right now).

    Thnx, Deb <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Pittsburgh, Pennsylvania, USA
    Thanked 342 Times in 335 Posts

    Re: Clipboard Paste fails (Excel 2002)

    Various things and tasks in excel will clear the clipboard. Setting the calculation mode is one of them (as you surmised).

    One option is to only set the mode if you are not in cut/copy mode:
    in Activate:
    <pre>If Application.CutCopyMode = False Then
    Application.Calculation = OrigCalcState</pre>

    in Deactivate:
    <pre>If Application.CutCopyMode = False Then
    Application.Calculation = xlCalculationAutomatic</pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts