+ Reply to Thread
Results 1 to 8 of 8

Copy-Pasting values into Notepad, then saving it

  1. #1
    Registered User
    Join Date
    09-13-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    27

    Copy-Pasting values into Notepad, then saving it

    Hello,

    I have a file from which I get specific values and need to copy-paste into a .txt file. (A certain program I use reads .txt files). I would then like to be able to have code that automatically saves the notepad with the name I desire.

    Also, I've found this code to open and copy paste, but I would like to avoid SendKeys (!!)

    Please Login or Register  to view this content.
    Thank you!

  2. #2
    Forum Contributor
    Join Date
    05-04-2012
    Location
    Stamford,Connecticut,USA
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Copy-Pasting values into Notepad, then saving it

    The code below will basically write the lines you have in your "Copied Range" into a text file, without opening Notepad.
    if you are satisfied with the answer click " * " add rep icon in the bottom left corner of my post

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-13-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Copy-Pasting values into Notepad, then saving it

    Thank you Raul!

    I removed strDirect and changed Myfile to "C:\Users\" & Environ$("Username") & "\Desktop\" & strFileName & ".txt" (found in another post) and everything works ALMOST perfectly: the first 20 or so values in the .txt have a space before the first character. Not-too-coincidentally, I imagine, these are all values which only have number characters (all other values have at least one letter character)

    Also, where in your code (which line) does it save? And what is #fnum?


    Thanks again!

  4. #4
    Forum Contributor
    Join Date
    05-04-2012
    Location
    Stamford,Connecticut,USA
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Copy-Pasting values into Notepad, then saving it

    The space must have been found in the range being written, please check the source range for blank spaces at the begining. This really doesnt save. It opens a file in the background for editing see instruction
    Please Login or Register  to view this content.
    ; Here is an explanation: http://zo-d.com/blog/archives/progra...ect-excel.html
    if you are satisfied with the answer click " * " add rep icon in the bottom left corner of my post

  5. #5
    Registered User
    Join Date
    09-13-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Copy-Pasting values into Notepad, then saving it

    Using the initial code I had, the spaces do not appear in the .txt
    Also, to confirm, there are no spaces before the value in the cells

    Huzzah!

  6. #6
    Forum Contributor
    Join Date
    05-04-2012
    Location
    Stamford,Connecticut,USA
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Copy-Pasting values into Notepad, then saving it

    if you are satisfied with the answer click " * " add rep icon in the bottom left corner of my post
    Also, Mark the thread as answer for others to reference it.

  7. #7
    Registered User
    Join Date
    09-13-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Copy-Pasting values into Notepad, then saving it

    I get it, you want reputation

    Yes, you answered my question, but you brought up another problem that wasn't there initially. I'll give you all the rep you want if you can fix it

  8. #8
    Forum Contributor
    Join Date
    05-04-2012
    Location
    Stamford,Connecticut,USA
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Copy-Pasting values into Notepad, then saving it

    OK why dont you just load a file sample and then I can see where the issue is, for the code only goes thru a loop in the "Copied Range" and writes it to the file line by line, if it finds empty spaces, empty columns or anything else that cannot be "printed" it still accounts for it. Without looking at your source data I can only guess, wich is not the best way to get an accurate answer.
    Forget about the reputation, if you dont feel like doing it is fine.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Need a second look at my macro for pasting in notepad
    By Nate87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2013, 04:53 PM
  2. how to copy selected notepad text and paste it in other notepad with macro
    By Guru232 in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 04-24-2013, 04:43 AM
  3. Help me in Copy the Values from Excel to Notepad and Save the Same.
    By karthik_13689 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2013, 05:55 AM
  4. Long Handed way of copy,pasting and saving worksheets
    By sajeel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-09-2010, 02:30 PM
  5. [SOLVED] Pasting from Notepad
    By Al in forum Excel General
    Replies: 1
    Last Post: 06-13-2005, 10:05 PM

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