+ Reply to Thread
Results 1 to 9 of 9

Not copying Excel to Notepad as CSV format

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Not copying Excel to Notepad as CSV format

    Macro needs to copy Excel worksheet, open Notepad and save data as a CSV file.

    But generates an error when setting strData = .GetText

    Code does not include the "last leg" which needs to convert the Tab separated form to a Comma separated one.

    Please Login or Register  to view this content.
    Trust someone can see the error? All solutions, suggestions and alternatives welcome as ever.

    Ochimus
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: Not copying Excel to Notepad as CSV format


    Hi,

    why using the clipboard instead of just saving directly the text file on the disk ? As Notepad is useless …

  3. #3
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Not copying Excel to Notepad as CSV format

    Possibly...
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: Not copying Excel to Notepad as CSV format

    Marc,

    I'm using Notepad because the End User wants the Excel data (not the whole sheet) in CSV form that then gets input to some other software.

    dangelor,

    Appreciate the equally prompt response, but the line is simply renaming the Excel file complete with the Macro button?

    I need the outcome to be a folder containing the original Excel file with Macro button and a text file in Notepad showing the data as CSV.

    Hope that clarifies?


    Ochimus

  5. #5
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Not copying Excel to Notepad as CSV format

    The code simply creates a 'comma delimited' text file named "TextCSV.txt" in the same folder as the workbook holding the code. You can then open the .txt file with any program you wish.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Not copying Excel to Notepad as CSV format


    Ochimus,

    as Excel can create a standard csv text file, you can first SaveCopyAs your source workbook to a temp one,
    open this temp one then apply the SaveAs to a csv file like Dangelor showed you in post #3, so easy in just 3 codelines …
    A 4th codeline is needed to just kill the temp workbook if necessary.
    Then if really really necessary you can launch Notepad to open the csv text file …
    Last edited by Marc L; 06-08-2021 at 11:28 AM.

  7. #7
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: Not copying Excel to Notepad as CSV format

    Thanks to both for input.

    Followed your path, which saves the data, but still having issues getting Notepad to open automatically and upload the CSV data automatically.

    Still don't understand why the original approach of copying the data to a clipboard, opening Notepad, and adding the info didn't work.

    Ochimus

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Not copying Excel to Notepad as CSV format

    Although I agree with other posters that you don't need to use clipboard...
    I tested your code and found no issues.

    Error must be specific to your environment.

    I removed section not needed, and ran code on my environment. No error generated and returned result fine.
    Please Login or Register  to view this content.
    When you expand Clipboard menu in Home ribbon. Do you see that it contains string? If it doesn't, that causes .GetText to throw error.

    0.JPG
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  9. #9
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Not copying Excel to Notepad as CSV format

    Possibly...
    Please Login or Register  to view this content.

+ 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] Copying and Pasting Data from Excel to Notepad
    By JSH2017 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-26-2018, 01:08 PM
  2. Opening Notepad a saved notepad file and copying the data on it
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2014, 06:18 PM
  3. Copying more than one range of data from excel into more than one notepad file
    By brianQ in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2013, 01:25 PM
  4. Copying Time from Notepad to Excel
    By CindyLisa in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 07-23-2011, 09:07 AM
  5. Copying excel info to notepad
    By shawnbecklar in forum Excel General
    Replies: 2
    Last Post: 12-11-2009, 11:07 PM
  6. Copying the data from two notepad files to an Excel workbook
    By raghunaik in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-10-2009, 12:17 AM
  7. copying data from excel into notepad
    By walid66 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-19-2007, 03:58 AM

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