Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006

    Red face Unanswered: Access 2003 Copy Paste problem

    I have several Access 2003 databases that the Copy Paste functions become disabled (grayed out) on a random basis. If I reboot, copy paste are active until they are used once or twice and then they become disabled. This happened on a client's windows xp system and my windows 2000 system. Not sure, but it may be related to the amount of data in the copy buffer.
    Has there been a recent access update that causes it to not clear the copy buffer? If so, how can I clear it without having to reboot?

    Help ...

  2. #2
    Join Date
    Apr 2004
    outside the rim
    The clipboard is one of those things we all take for granted, but is a bit touchy under the hood (try programatically placing an image on the clipboard someday!)

    Perhaps it has to do with the multi position clipboard newer versions of Office offer, which is not the same tool as the standard Windows clipboard. I don't know the specific answer to your question, but this may help you "unlock" the clipboard when Access has determined the buttons should be disabled.

    Place this in a module:
    Option Compare Database
    Option Explicit
    Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
    Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
    Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
    Declare Function CloseClipboard Lib "User32" () As Long
    Declare Function OpenClipboard Lib "User32" (ByVal hwnd As Long) As Long
    Declare Function EmptyClipboard Lib "User32" () As Long
    Declare Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long
    Declare Function SetClipboardData Lib "User32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
    Public Const GHND = &H42
    Public Const CF_TEXT = 1
    Sub CtlC(SomeString As Variant)
        Dim hGlobalMemory As Long
        Dim lpGlobalMemory As Long
        Dim hClipMemory As Long
        Dim X As Long
        Dim MyString As String
        If IsNull(SomeString) Then MyString = "" Else MyString = SomeString
        ' Allocate movable global memory.
        hGlobalMemory = GlobalAlloc(GHND, Len(MyString) + 1)
        ' Lock the block to get a far pointer
        ' to this memory.
        lpGlobalMemory = GlobalLock(hGlobalMemory)
        ' Copy the string to this global memory.
        lpGlobalMemory = lstrcpy(lpGlobalMemory, MyString)
        ' Unlock the memory.
        If GlobalUnlock(hGlobalMemory) <> 0 Then
           MsgBox "Could not unlock memory location. Copy aborted."
           GoTo OutOfHere2
        End If
        ' Open the Clipboard to copy data to.
        If OpenClipboard(0&) = 0 Then
           MsgBox "Could not open the Clipboard. Copy aborted."
           Exit Sub
        End If
        ' Clear the Clipboard.
        X = EmptyClipboard()
        ' Copy the data to the Clipboard.
        hClipMemory = SetClipboardData(CF_TEXT, hGlobalMemory)
        If CloseClipboard() = 0 Then
           MsgBox "Could not close Clipboard."
        End If
    End Sub
    To use the "Control-C" function:
    CtlC("Some string of text ...")
    This places the string of text on the clipboard (replacing whatever is there).

    This came from the web years ago; I can not site the specific source
    have fun!

    Todd S.
    click to email

    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET

    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

Posting Permissions

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