+ Reply to Thread
Results 1 to 13 of 13

Various pasting issues

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Various pasting issues

    Hello everyone.

    I need some help on some pasting issues I have in code (Excel 2007).

    So a user open an excel spreadhseet and a userform pops open. The form has two textboxes and two buttons. In the first textbox a a date (shorthand) is entered. The user presses a button and a file with that date extension is retrieved. Upon opening the file the user is prompted to select an area to copy.

    Please Login or Register  to view this content.
    Now the user goes back to the userform and enters some text in a TextBox. After that she presses a button which creates and opens a new Excel file and is supposed to paste CPSelection.

    Please Login or Register  to view this content.
    I get two errors on various runs. One informs me that I have a paste method fail. The other informs me that I do not have enough room on the clipboard.

    Any ideas?
    Last edited by AnthonyWB; 05-31-2011 at 11:31 AM. Reason: Issue merged into another problem

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Various pasting issues

    Hi,

    Look at the examples on http://www.ozgrid.com/forum/showthread.php?p=111223

    You Copy to the clipboard and then go to somewhere else and need to select a cell.
    You need to do a
    Please Login or Register  to view this content.
    and then do the
    Please Login or Register  to view this content.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Various pasting issues

    Correction to my previous post. Actually I do in fact have Range(A1").Select.

  4. #4
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Various pasting issues

    Actually I am now getting a new error.

    I changed the PasteSpecial to Paste and now encounter an "object Doesn't support this property or method"

  5. #5
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Various pasting issues

    I have tried to use

    Please Login or Register  to view this content.


    and I recieve a "PasteSpecial method Rangle Class Failed"

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Various pasting issues

    What is your CPSelection Dimed as? Is it a range of cells? Are you sure?

  7. #7
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Various pasting issues

    MarvivP

    Its dimes as :

    Dim CPSelection As Range.

    It's done so gloablly. Right below the Option Explicit. Could that be the cause?

  8. #8
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Various pasting issues

    I am still getting an error here. The first error I get indicates that the paste method is not supported? When I used th immediate window :

    Please Login or Register  to view this content.
    to investigate, it informs me that the "Data on the clipboard is not the same size.......". Any further sugggestions?


    Please Login or Register  to view this content.

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649
    Why copying ?
    Why 2 commandbuttons ?
    Why writing to the same drive where the OS resides ?

    Please Login or Register  to view this content.
    Last edited by snb; 05-31-2011 at 12:50 PM.



  10. #10
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Various pasting issues

    Thanks. I am not sure your code will run. Maybe take a double look at it?

  11. #11
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Various pasting issues

    This is impressive but this part is showing up red


    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Various pasting issues

    So it doesn't quite run. Its indicating that a variable is undefined. But it seems as though all variables are defined?

    Please Login or Register  to view this content.
    Now c00 is highlighted in blue, but Public Sub CommandButton1_Click()
    is highlighted in yellow.

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Various pasting issues

    Please remove Option Explicit; you won't need it.
    I adapted the code in post #9.

+ 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