+ Reply to Thread
Results 1 to 15 of 15

Copy from excel to notepad.

  1. #1
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Copy from excel to notepad.

    Hello!

    I would like to make a macro which selects an area i.e. d1 to g5.
    1) then copy and paste into a new notepad, saved with a name by text in cell a1.
    2) Or copies at the end of an already existing notepad, name given of the document in cell b2.

    The filepath i.e. c:\ can be defined within the macro.

    Cheers

  2. #2
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Smile Re: Copy from excel to notepad.

    I have searched the net, but haven't found anything usefull on my problem. The one macro I've found worth having a closer look at is this:

    Please Login or Register  to view this content.
    The problem is, that my version of office (excel 2003), doesn't understand the ctrl-v sendkey sentence. I would also like to being able to set the macro to open certain notepadfiles instead of just running notepad.exe.

  3. #3
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Copy from excel to notepad.

    This is a couple of methods for writing to a text file:

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Copy from excel to notepad.

    To append you can use similar to the first example:

    Please Login or Register  to view this content.

    Dom

  5. #5
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Copy from excel to notepad.

    Hi!

    Thanks for your help, instead for selection A1:A1, is it possible to integrate:
    Range(Selection, Selection.End(xlDown))

    I wasn't able to do it.

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Copy from excel to notepad.

    It's usually better to go up rather than down:

    Please Login or Register  to view this content.

    Dom

  7. #7
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Copy from excel to notepad.

    Thanks for quick reply

    Please Login or Register  to view this content.
    "Object doesn't support this property or method" any idea? I need to referr to document and sheet.

  8. #8
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Copy from excel to notepad.

    Try:

    Please Login or Register  to view this content.

    Dom

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

    Re: Copy from excel to notepad.

    Please Login or Register  to view this content.



  10. #10
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Copy from excel to notepad.

    Thanks it works perfect. Thanks! Now I just have to learn the append thing
    Last edited by Hjahren; 09-10-2010 at 08:41 AM.

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

    Re: Copy from excel to notepad.

    B16 can contain 'forbidden' characters in filenames.
    In your case you'd better use Output then Append.
    Please Login or Register  to view this content.
    Last edited by snb; 09-10-2010 at 08:45 AM.

  12. #12
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Copy from excel to notepad.

    Hello!

    I have a problem with appending to an already existing document. The name of the existing document is given in fNEW.

    How can I select the area from a2-f2 and "end row". These are the rows I want to append. I know that this code is making a new text document.

    Please Login or Register  to view this content.
    Last edited by Hjahren; 09-14-2010 at 05:03 AM.

  13. #13
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Copy from excel to notepad.

    Maybe my question yesterday was a bit confusing.

    I want to make a macro which appends cells from excel to an existing textdocument.
    The macro should be able to:
    1. Open a textfile with name given from a spreadsheet iex cell "a1".
    2. Copy cell a2:f2 and all the rows with text beneath.

  14. #14
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Copy from excel to notepad.

    This version of append pastes the text underneath eachother and does not seperate into regular columns as a normal copy and paste would do.

    Anything I could try different?

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Copy from excel to notepad.

    The macros work fine when it is one row that shall be appended, but not when the columns are from a to f. Anyone who knows why?

    I would much appreciate your contribution. I need this to finish my project...

+ 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