Exporting to Notepad - Select file name?

SpeedyKevin

New Member
Joined
Apr 26, 2019
Messages
17
Hello all!

I have the macro below that exports certain columns to a file (in this a m3u8 file). Is there a way I could have excel allow me to type in the file name I'd prefer before exporting?


Thanks,
Kevin





Sub ExportToNotepadOVERALL()


Sheets("OVERALL_CLIPS").Select

WriteRangeToTextFile Range("D6:D86"), "file4.m3u8", vbTab


Sheets("Sheet1").Select





Shell "notepad.exe file4.m3u8", vbMaximizedFocus




End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try this

Code:
Sub ExportToNotepadOVERALL()
    Sheets("OVERALL_CLIPS").Select
[COLOR=#0000ff]    wname = InputBox("Enter file name")[/COLOR]
[COLOR=#0000ff]    If wname = "" Then Exit Sub[/COLOR]
    WriteRangeToTextFile Range("D6:D86"), [COLOR=#0000ff]wname[/COLOR], vbTab
    Sheets("Sheet1").Select
    Shell "notepad.exe file4.m3u8", vbMaximizedFocus
End Sub
 
Upvote 0
Try this

Code:
Sub ExportToNotepadOVERALL()
    Sheets("OVERALL_CLIPS").Select
[COLOR=#0000ff]    wname = InputBox("Enter file name")[/COLOR]
[COLOR=#0000ff]    If wname = "" Then Exit Sub[/COLOR]
    WriteRangeToTextFile Range("D6:D86"), [COLOR=#0000ff]wname[/COLOR], vbTab
    Sheets("Sheet1").Select
    Shell "notepad.exe file4.m3u8", vbMaximizedFocus
End Sub

Hello Dante!

Thanks for the reply, I tried using the Macro but get a Compile Error: Ambiguous name detected: WriteRangeToTextFile
 
Upvote 0
That's because you have 2 times or more this macro "WriteRangeToTextFile" in the same module
 
Upvote 0
Try:

Code:
Sub ExportToNotepadOVERALL()
    Sheets("OVERALL_CLIPS").Select
    wname = InputBox("Enter file name")
    If wname = "" Then Exit Sub
    WriteRangeToTextFile Range("D6:D86"), wname [B][COLOR=#0000ff]& ".m3u8"[/COLOR][/B], vbTab
    Sheets("Sheet1").Select
    Shell "notepad.exe file4.m3u8", vbMaximizedFocus
End Sub
 
Upvote 0
Try:

Code:
Sub ExportToNotepadOVERALL()
    Sheets("OVERALL_CLIPS").Select
    wname = InputBox("Enter file name")
    If wname = "" Then Exit Sub
    WriteRangeToTextFile Range("D6:D86"), wname [B][COLOR=#0000ff]& ".m3u8"[/COLOR][/B], vbTab
    Sheets("Sheet1").Select
    Shell "notepad.exe file4.m3u8", vbMaximizedFocus
End Sub

Hot ****! its nearly perfect! My final quesiton would be regarding this line

Shell "notepad.exe file4.m3u8", vbMaximizedFocus

I've been trying to get it to open the file we just created but can't seem to do it. I tried replacing the generic file name with "wname.m3u8" but that didn't work. Thoughts?
 
Upvote 0
Never mind got it to work with this
Shell "notepad.exe " & wname & ".m3u8", vbMaximizedFocus


Thanks for the help! Really appreciate it!
 
Upvote 0
How about:

Code:
Sub ExportToNotepadOVERALL()
    Sheets("OVERALL_CLIPS").Select
    wname = InputBox("Enter file name")
    If wname = "" Then Exit Sub
    WriteRangeToTextFile Range("D6:D86"), wname & ".m3u8", vbTab
    Sheets("Sheet1").Select
    Shell "notepad.exe " & wname & ".m3u8", vbMaximizedFocus
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,603
Members
449,089
Latest member
Motoracer88

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