VBA - Open a .csv in Notepad

sanantonio

Board Regular
Joined
Oct 26, 2021
Messages
124
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Could I please get some help?

In order to upload data in SAP I export data from another source, run it through my formatting tool and produce a .csv file. Unfortunately the concat I require to make the data readable in SAP includes a comma so the .csv will always save with "
1671133070989.png


Of course the "s aren't visible when the .csv is opened in Excel, only in Notepad. But if you try and upload to SAP without opening notepad, doing a ctrl+h and getting rid of all the "s.

In an ideal word I'd like a code that opens it in notepad, removes the "s for me and saves it again. But I'm not greedy. I'd settle for just a code that opens the .csv in Notepad for me?

I try...
VBA Code:
Sub WHATEVER()
    CreateObject("Shell.Application").Open ("filepath\20221215.csv")
End Sub

But of course this just opens the .csv in excel.

Could any of you fine folks help me out?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try this:
VBA Code:
Shell "notepad.exe filepath\20221215.csv", vbNormalFocus

Of course the "filepath\20221215.csv" part needs to be an actual valid file path.
 
Upvote 0
Solution
That's amazing it works thank you!
One last test though I need the file name to reference a cell. But it doesn't seem to work when I do that?

VBA Code:
Sub test()
Shell "notepad.exe L:\filepath\" & "Sheet5.Range("H1") & ".csv", vbNormalFocus

End Sub

Am I missing something here? It just flashes read when I try this?
 
Upvote 0
You have an extra double quote. It should be . . .

VBA Code:
Shell "notepad.exe L:\filepath\" & Sheet5.Range("H1").Value & ".csv", vbNormalFocus

You'll also notice that I have specified the Value property of the Range object for clarity.

Cheers!
 
Upvote 0

Forum statistics

Threads
1,214,914
Messages
6,122,211
Members
449,074
Latest member
cancansova

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