+ Reply to Thread
Results 1 to 9 of 9

Clearing Clipbaord problem

  1. #1
    Registered User
    Join Date
    07-15-2008
    Location
    germany
    Posts
    56

    Clearing Clipbaord problem

    Hi freinds,

    I was currently trying to delete my clipbaord because it copies a lot of data and it has slowed down the macro a bit.
    I have tried with the following code but it is not working

    PHP Code: 
    Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
    Public Declare Function EmptyClipboard Lib "user32" () As Long
    Public Declare Function CloseClipboard Lib "user32" () As Long

    Sub ClearClipboard
    ()
        
    OpenClipboard (0&)
        
    EmptyClipboard
        CloseClipboard
    End Sub 
    PHP Code: 
    application.cutcopymode=false 
    on the other just deactivates it which I dont want. Any ideas from your side.
    Thanks in advance

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Clearing Clipbaord problem

    If you are talking about the Office clipboard, as opposed to the Windows clipboard, then the API functions won't work.
    If possible you should do your copy/paste in one line, using the Destination argument of the copy method.
    Remember what the dormouse said
    Feed your head

  3. #3
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Re: Clearing Clipbaord problem

    hi dude, i had this problem before and this was the solution:

    Please Login or Register  to view this content.
    Then just execute

    EmptyClipboard
    Mr MaGoo
    Magoo.Inc MMVII

    If i've helped please add to my Rep by Clicking on the Blue Scales in the top right hand corner of the post

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Clearing Clipbaord problem

    I'm struggling to see how that is different from what was posted originally?

  5. #5
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Re: Clearing Clipbaord problem

    yeah good point actually romper?

    it's a little diff but nothing to say it shouldn't work the same.

    it worked fine on my workbook?

    adyan76 how are you calling the function and where?
    Last edited by Macdave_19; 07-30-2009 at 09:49 AM.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Clearing Clipbaord problem

    Quote Originally Posted by Macdave_19 View Post
    it's a little diff
    only in as much as there's a check to see the OpenClipboard returned a value! (The actual functions are all exactly the same)

  7. #7
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Re: Clearing Clipbaord problem

    what can i say i'm nit picking lol!! ha ha ha

  8. #8
    Registered User
    Join Date
    07-15-2008
    Location
    germany
    Posts
    56

    Re: Clearing Clipbaord problem

    the following code is collectiong the data in clipboard

    PHP Code: 
      Range("A:A").EntireColumn.Hidden True
        Columns
    ("F:F").Copy
        Columns
    ("B:B").Insert Shift:=xlToRight
        Range
    ("G:G,I:I").Delete Shift:=xlToLeft
        Columns
    ("M:M").Copy
        Columns
    ("I:I").Insert Shift:=xlToRight
        Columns
    ("N:N").Delete Shift:=xlToLeft
        Columns
    ("Q:Q").Copy
        Columns
    ("J:J").Insert Shift:=xlToRight
        Columns
    ("R:R").Delete Shift:=xlToLeft
       Range
    ("A:A,O:O,R:R,S:T,U:U,V:W,AB:AB,AJ:AJ,CI:CK,AG:AI,AK:AK,AN:AS,AU:CH,CL:CL").EntireColumn.Hidden True
        Range
    ("B1").Activate 
    I had the same issue in other part of code and by using destination command together with copy i fixed it like
    PHP Code: 
     Selection.Copy Destination:=Sheets("xyz").Range("n65536").End(xlUp).Offset(1, -13
    but how can I do the same with the code written above.
    Thanks for your responces and sorry for my laste response.

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Clearing Clipbaord problem

    Insert the destination columns first, then do the copy and paste directly.

+ 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