Clipboard Problem using VBA

Discussion in 'Word Programming' started by, Apr 6, 2012.

  1. Guest

    Hi everybody,

    I've a stange behavior in my macro (Windows XP SP3, Office 2002 SP3) :

    I try to copy and paste some text from a word document to another (from an excel VBA project).

    I use this kind of code :

    It works most of the time...

    But with some computers, instead of copying doc1 to doc2... It just paste a bitmap icon in doc2. I don't even know where does it come from !

    Has somenone an idea ? I'm completely lost !
    The most strange : if I put a break point after doc1.ActiveDocument.Content.Copy, and try to paste in another document, it works ! VBA Memory leak ?

    Thanks a lot.
    , Apr 6, 2012
    1. Advertisements

  2. Auric__ Guest

    You could try clearing the clipboard before your code:

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

    Sub foo()
    OpenClipboard 0
    End Sub

    Don't know if that would solve your problem, though.
    Auric__, Apr 7, 2012
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.