+ Reply to Thread
Results 1 to 6 of 6

How to lock the clipboard

  1. #1
    John Austin
    Guest

    How to lock the clipboard

    I have a VB app that creates an instance of Excel, and then intensively gets
    Excel to copy and paste data between worksheets. The problem that I have is
    that whilst this is going on (for about 5 minutes), if the user copies data
    in another application, then that data is pasted into Excel instead of the
    data that was intended.

    How can Excel 'lock' the clipboard between the Copy and Paste commands so as
    to ensure that this does not happen?

    John Austin

  2. #2
    Dick Kusleika
    Guest

    Re: How to lock the clipboard

    John

    I generally copy cells when I need more than just the value (e.g.
    formatting, data validation). If I just need the value, I set the Value
    property of the destination cell equal to the Value property of the source
    cell. This avoids the clipboard and will probably be faster.

    Five minutes of copying is quite a bit, unless you're running a 486 machine.
    I would concentrate on getting that five minutes down to under 30 seconds.
    If you describe what you're doing, maybe someone can help you do that.

    I don't know of any way to lock the clipboard without locking out the whole
    computer.


    --
    **** Kusleika
    Excel MVP
    Daily Dose of Excel
    www.*****-blog.com


    John Austin wrote:
    > I have a VB app that creates an instance of Excel, and then
    > intensively gets Excel to copy and paste data between worksheets. The
    > problem that I have is that whilst this is going on (for about 5
    > minutes), if the user copies data in another application, then that
    > data is pasted into Excel instead of the data that was intended.
    >
    > How can Excel 'lock' the clipboard between the Copy and Paste
    > commands so as to ensure that this does not happen?
    >
    > John Austin




  3. #3
    John Austin
    Guest

    Re: How to lock the clipboard

    Hello ****,

    The 4 minutes is actually mainly data insertion - it takes a long time
    because the workbook is big. Up to 20 sheets each 250 rows by 90 colums. The
    only things that are actually copied are formatting and formulae. If the
    machine were locked for the duration of the copy / paste at least it would
    avoid corruption of the formulae.

    As an aside, I did try making the VB6 data insertion routine into an
    active-x dll so that it could be called from within the Excel application
    in-process. This resulted in startling performance improvements but I got
    some weird errors that were impossible to debug.
    --
    John Austin


    "**** Kusleika" wrote:

    > John
    >
    > I generally copy cells when I need more than just the value (e.g.
    > formatting, data validation). If I just need the value, I set the Value
    > property of the destination cell equal to the Value property of the source
    > cell. This avoids the clipboard and will probably be faster.
    >
    > Five minutes of copying is quite a bit, unless you're running a 486 machine.
    > I would concentrate on getting that five minutes down to under 30 seconds.
    > If you describe what you're doing, maybe someone can help you do that.
    >
    > I don't know of any way to lock the clipboard without locking out the whole
    > computer.
    >
    >
    > --
    > **** Kusleika
    > Excel MVP
    > Daily Dose of Excel
    > www.*****-blog.com
    >
    >
    > John Austin wrote:
    > > I have a VB app that creates an instance of Excel, and then
    > > intensively gets Excel to copy and paste data between worksheets. The
    > > problem that I have is that whilst this is going on (for about 5
    > > minutes), if the user copies data in another application, then that
    > > data is pasted into Excel instead of the data that was intended.
    > >
    > > How can Excel 'lock' the clipboard between the Copy and Paste
    > > commands so as to ensure that this does not happen?
    > >
    > > John Austin

    >
    >
    >


  4. #4
    Dick Kusleika
    Guest

    Re: How to lock the clipboard

    John Austin wrote:
    >
    > The 4 minutes is actually mainly data insertion - it takes a long time
    > because the workbook is big. Up to 20 sheets each 250 rows by 90
    > colums. The only things that are actually copied are formatting and
    > formulae. If the machine were locked for the duration of the copy /
    > paste at least it would avoid corruption of the formulae.


    It still seems like a long time. I can populate that many cells in 88
    seconds on my dinosaur of a computer from VBA in Excel. Maybe the
    automation is creating the overhead.

    I don't know VB6 well enough to know if there's a better solution, but you
    could find some APIs that disable the keyboard and the mouse. That would
    prevent the user from doing anything until your program is done.

    --
    **** Kusleika
    Excel MVP
    Daily Dose of Excel
    www.*****-blog.com



  5. #5
    okaizawa
    Guest

    Re: How to lock the clipboard

    Hi,

    Excel seems to be able to copy and paste in an instance without using
    the clipboard. how about something like this?

    Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
    Declare Function CloseClipboard Lib "user32" () As Long
    Declare Function EmptyClipboard Lib "user32" () As Long


    If OpenClipboard(0) = 0 Then
    MsgBox "cannot open clipboard."
    ElseIf EmptyClipboard() = 0 Then
    MsgBox "cannot clear clipboard."
    Else

    'code to copy and paste

    CloseClipboard
    End If

    --
    HTH,

    okaizawa


    John Austin wrote:
    > I have a VB app that creates an instance of Excel, and then intensively gets
    > Excel to copy and paste data between worksheets. The problem that I have is
    > that whilst this is going on (for about 5 minutes), if the user copies data
    > in another application, then that data is pasted into Excel instead of the
    > data that was intended.
    >
    > How can Excel 'lock' the clipboard between the Copy and Paste commands so as
    > to ensure that this does not happen?
    >
    > John Austin


  6. #6
    John Austin
    Guest

    Re: How to lock the clipboard

    This looks very promising - thanks, I will try it out!
    --
    John Austin


    "okaizawa" wrote:

    > Hi,
    >
    > Excel seems to be able to copy and paste in an instance without using
    > the clipboard. how about something like this?
    >
    > Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
    > Declare Function CloseClipboard Lib "user32" () As Long
    > Declare Function EmptyClipboard Lib "user32" () As Long
    >
    >
    > If OpenClipboard(0) = 0 Then
    > MsgBox "cannot open clipboard."
    > ElseIf EmptyClipboard() = 0 Then
    > MsgBox "cannot clear clipboard."
    > Else
    >
    > 'code to copy and paste
    >
    > CloseClipboard
    > End If
    >
    > --
    > HTH,
    >
    > okaizawa
    >
    >
    > John Austin wrote:
    > > I have a VB app that creates an instance of Excel, and then intensively gets
    > > Excel to copy and paste data between worksheets. The problem that I have is
    > > that whilst this is going on (for about 5 minutes), if the user copies data
    > > in another application, then that data is pasted into Excel instead of the
    > > data that was intended.
    > >
    > > How can Excel 'lock' the clipboard between the Copy and Paste commands so as
    > > to ensure that this does not happen?
    > >
    > > John Austin

    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1