Excel to notepad macro

RLA

New Member
Joined
Feb 24, 2010
Messages
20
Hello,
I am looking for help in getting a range of excel data pasted into an existing notepad file at line 202 and saving the file with name from a cell and a .stp extension.

The range is in column a1:a150

If I could then open the resulting file with another application that would be the greatest.

Thanks for any help.

Rick
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Code:
Sub TxtToStp()
    Open "myfile.txt" For Input As #1
    Open "mynewfile.stp" For Output As #2
    For Row = 1 To 202
        Line Input #1, x
        Print #2, x
    Next Row
    For Row = 1 To 150
        Print #2, Cells(Row, 1)
    Next Row
    While Not EOF(1)
        Line Input #1, x
        Print #2, x
    Wend
    Close
End Sub
 
Upvote 0
diddi,

Thanks so much, the copy,paste save as works great!

If I wanted to add open resultant file with another application is that possible from within excel?

The application name is "Alibre Design"

Thanks,
Rick
 
Upvote 0
you will need to use the Shell command. i dont have the program you are talking about, but to open the command prompt you would use

Code:
Shell "cmd.exe",vbnormalfocus

so i am guessing you will need to find the exact name of the .exe and put it in.
 
Upvote 0
diddi,
Something happened so that after working with the code you gave for the paste and save for a few hours, now I am getting a file not found error for the first .txt file. I may have changed it but the name matches in the code. Any idea of a common error?

Thanks,

Rick
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top