Macros that open software

Ron Strowger

New Member
Joined
Oct 16, 2015
Messages
3
Can a macro export a range of cells to tab delimited into notepad, open word to open the notepad file, remove the tab between the cells (A, B, C, D...) and insert a manual line break then save it as text? I can do all this pretty easily with manual steps from excel on through word but it requires the time to open and close each program through the steps. I am just learning macros and this is a big learning curve.
 
There is no need to use Word or Notepad for this: it can all be done directly from Excel. For example:
Code:
Sub Demo()
Dim i As Long, j As Long, StrOut As String
With ActiveSheet
  For i = 1 To 10
    For j = 1 To 10
      StrOut = StrOut & .Cells(i, j).Text & vbCrLf
    Next
  Next
End With
Open "C:\Users\" & Environ("UserName") & "\Documents\Output.txt" For Output As #1
Print #1, StrOut
Close #1
End Sub
The above code will output A1:J10 on separate lines in a file named Output.txt in your Documents folder.
 
Upvote 0

Forum statistics

Threads
1,226,850
Messages
6,193,338
Members
453,790
Latest member
yassinosnoo1

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