+ Reply to Thread
Results 1 to 9 of 9

Excel to notepad

  1. #1
    Registered User
    Join Date
    06-21-2015
    Location
    india
    MS-Off Ver
    2010
    Posts
    6

    Post Excel to notepad

    Hi All,

    I have write one program to copy one range to notepad but i am not able to the notepad automatically to mentioned path please solve the problem.
    Please Login or Register  to view this content.
    Here i need code to save the notepad to certain directory.

    Thank & Regards
    vinay krishna
    Last edited by vinay krishna; 06-21-2015 at 11:59 PM.

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Excel to notepad

    Hi,

    Welcome to the forum. Please take your time to read forum rules here :
    http://www.excelforum.com/forum-rule...rum-rules.html

    As forum rules #3, you must :
    Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button). The result will appear like this in the post window:

    Please Login or Register  to view this content.
    Please edit your post and add this code tag.



    About your problem, instead of launch notepad and sending simulated keystroke to this window, it is better to work with the clipboard object directly.
    The code would be something like this :

    Please Login or Register  to view this content.

    Regards

  3. #3
    Registered User
    Join Date
    06-21-2015
    Location
    india
    MS-Off Ver
    2010
    Posts
    6

    Re: Excel to notepad

    thank you so much for your reply really it help me a lot i tried this code its working perfect with me......
    and one more help i need,while coping there is any chance for skipping blank line and length of character like 5 to 6 digits to skip if it will not meet sufficient length of charactor

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Excel to notepad

    You are welcome Vinay.

    But before we continue, please go to your first post and hit "Edit Post" button and add the code tag to your code, as the forum rules, this is a must.

  5. #5
    Registered User
    Join Date
    06-21-2015
    Location
    india
    MS-Off Ver
    2010
    Posts
    6

    Re: Excel to notepad

    what is code tag and how to add i am new to this forum

  6. #6
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Excel to notepad

    By using code tag, the text between this tag will be appeared inside a box like my post in #2.

    To do this :
    click the "Edit Post" button

    select the text you want to put in this box (from the word "Sub" until "End Sub"), and then press the "#" button.

    Your text will become like this :
    [CODE]But before we[/CODE]

    Then click the "Save" button

  7. #7
    Registered User
    Join Date
    06-21-2015
    Location
    india
    MS-Off Ver
    2010
    Posts
    6

    Re: Excel to notepad

    Sub NOTEPAD()
    Dim str1 As String, FileToSave As String

    FileToSave = "Z:\Report.txt"
    Range("A1:A500").Copy

    'Get clipboard content and assign it to str1 variable
    With CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") 'Clipboard object
    On Error Resume Next
    .GetFromClipboard
    str1 = .GetText(1)
    On Error GoTo 0
    End With

    'Write to file
    If Len(str1) Then
    Open FileToSave For Output As #1
    Print #1, str1
    Close #1
    End If
    Application.CutCopyMode = False
    End Sub
    #

  8. #8
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Excel to notepad

    This is how you should do it :

    - Click the the "Edit Post" button
    - Using mouse, select (highlight) the part of text you want to put inside the box
    - Click the "#" button
    - Click "Save" button

    AddCodeTag.GIF

  9. #9
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Excel to notepad

    Nice work Vinay, you finally have figured out how to display the code properly. By doing this, you will prevent got warnings from moderators and other forum members in the future.

    Now about you request to skip blank lines and lines with less than 6 characters, this is the code :

    Please Login or Register  to view this content.
    Please note the highlighted line :
    If .... > 6 Then ....
    any line with less than 6 chars (including blank lines) will be skipped by using this statement.



    Regards

+ 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] Save Notepad through VBA Macro, having Copied Range of Cells, Pasted into notepad
    By analystbank in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-22-2014, 02:14 AM
  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. [SOLVED] Notepad to excel and back to notepad
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2014, 10:33 AM
  4. Remove marching ants after notepad macro opens notepad
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 01-07-2014, 09:47 PM
  5. 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

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