+ Reply to Thread
Results 1 to 7 of 7

Clipboard Question

  1. #1
    Himansu
    Guest

    Clipboard Question


    Hello everyone,

    I have a section of a macro that imports a file
    and copies the contents of the entire worksheet
    into another workbook. I keep getting this
    prompt message:

    'There is a large amount of information on the
    Clipboard. Do you want to be able to paste
    this information into another program later?'

    * I cleared all the contents on the clipboard and
    in cache memory, but every time I execute the
    macro I keep getting this prompt. Is there any
    way to just default to 'yes' and remove this?
    Is this happening because I'm copying the entire
    worksheet?

    Any input will be greatly appreciated.

    Thanks,
    Himansu



  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon Himansu

    Try inserting this line after you've done your copying:

    Application.CutCopyMode = False

    HTH

    DominicB

  3. #3
    Himansu
    Guest

    Re: Clipboard Question

    Hello DominicB,

    Tried your suggestion. I got an error. Here's
    a part of the code:

    --
    Columns("A:A").Select
    Cells.Select
    Selection.Copy
    Range("A1").Select
    Application.CutCopyMode = False ' added 12/05/05 12:05 PM EST
    ActiveWindow.Close
    ActiveSheet.Paste
    --

    * Let me know what you think.

    Thanks,
    Himansu

    "dominicb" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Good afternoon Himansu
    >
    > Try inserting this line after you've done your copying:
    >
    > Application.CutCopyMode = False
    >
    > HTH
    >
    > DominicB
    >
    >
    > --
    > dominicb
    > ------------------------------------------------------------------------
    > dominicb's Profile:

    http://www.excelforum.com/member.php...o&userid=18932
    > View this thread: http://www.excelforum.com/showthread...hreadid=490783
    >




  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi Himansu

    You put the line in the wrong place. You copied data onto the clipboard, and then effectively cancelled it with the CutCopyMode = False statement.

    Using your code, I switched the lines around a bit to give me this:

    Columns("A:A").Select
    Cells.Select
    Selection.Copy
    Range("A1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False ' added 12/05/05 12:05 PM EST
    ActiveWindow.Close

    which works without a hitch.

    HTH

    DominicB

  5. #5
    Himansu
    Guest

    Re: Clipboard Question

    Hi DominicB,

    Once the contents of the cells are (1) copied
    that worksheet is (2) closed, then the data
    that is copied is (3) pasted into the active worksheet.

    Let me know if you need me to elaborate more
    on this.

    Thanks,
    Himansu



  6. #6
    Jim Thomlinson
    Guest

    Re: Clipboard Question

    Here is some code for you. You need to know the name of the sheet and book
    that you intend to copy the data into for this to work. That is a whole lot
    safer than pasting to the active workbook once the current window is closed...

    Sub Test()
    Dim wbkSource As Workbook
    Dim wbkDestination As Workbook
    Dim wksSource As Worksheet
    Dim wksDestination As Worksheet
    Dim rngSource As Range
    Dim rngDestination As Range

    'Set your source
    Set wbkSource = ThisWorkbook
    Set wksSource = wbkSource.Sheets("Sheet1")
    Set rngSource = wksSource.Cells

    'Set your destination
    On Error GoTo OpenBook
    Set wbkDestination = Workbooks("ThatBook.xls")
    On Error GoTo 0
    Set wksDestination = wbkDestination.Sheets("Sheet1")
    Set rngDestination = wksDestination.Range("A1")

    'You now have all of your souce and destination objects

    rngSource.Copy rngDestination

    Exit Sub

    OpenBook:
    Set wbkDestination = Workbooks.Open("C:\Thatbook.xls")
    Resume Next
    Exit Sub

    End Sub
    --
    HTH...

    Jim Thomlinson


    "Himansu" wrote:

    > Hi DominicB,
    >
    > Once the contents of the cells are (1) copied
    > that worksheet is (2) closed, then the data
    > that is copied is (3) pasted into the active worksheet.
    >
    > Let me know if you need me to elaborate more
    > on this.
    >
    > Thanks,
    > Himansu
    >
    >
    >


  7. #7
    Himansu
    Guest

    Re: Clipboard Question

    Jim,

    Thanks for the info. I'll embed this into my
    code. I have a lot more re-work to do now.
    * Your idea makes sense.

    Thanks,
    Himansu

    "Jim Thomlinson" <[email protected]> wrote in message
    news:[email protected]...
    > Here is some code for you. You need to know the name of the sheet and book
    > that you intend to copy the data into for this to work. That is a whole

    lot
    > safer than pasting to the active workbook once the current window is

    closed...
    >
    > Sub Test()
    > Dim wbkSource As Workbook
    > Dim wbkDestination As Workbook
    > Dim wksSource As Worksheet
    > Dim wksDestination As Worksheet
    > Dim rngSource As Range
    > Dim rngDestination As Range
    >
    > 'Set your source
    > Set wbkSource = ThisWorkbook
    > Set wksSource = wbkSource.Sheets("Sheet1")
    > Set rngSource = wksSource.Cells
    >
    > 'Set your destination
    > On Error GoTo OpenBook
    > Set wbkDestination = Workbooks("ThatBook.xls")
    > On Error GoTo 0
    > Set wksDestination = wbkDestination.Sheets("Sheet1")
    > Set rngDestination = wksDestination.Range("A1")
    >
    > 'You now have all of your souce and destination objects
    >
    > rngSource.Copy rngDestination
    >
    > Exit Sub
    >
    > OpenBook:
    > Set wbkDestination = Workbooks.Open("C:\Thatbook.xls")
    > Resume Next
    > Exit Sub
    >
    > End Sub
    > --
    > HTH...
    >
    > Jim Thomlinson
    >
    >
    > "Himansu" wrote:
    >
    > > Hi DominicB,
    > >
    > > Once the contents of the cells are (1) copied
    > > that worksheet is (2) closed, then the data
    > > that is copied is (3) pasted into the active worksheet.
    > >
    > > Let me know if you need me to elaborate more
    > > on this.
    > >
    > > Thanks,
    > > Himansu
    > >
    > >
    > >




+ 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