Hi,
I have some code that copies data from excel to a .txt file . I can successfully copy the data into the .txt file but I am having two issues.
1. Is there a way that the code opens the .txt workbook in notepad ++ rather than notepad
2. I am trying to add a filename and save the .txt file but the code I have is not working, I copied some code that works for excel in naming and saving documents but it is not working for the txt file.
Any help is greatly appreciated.
Code below
I have some code that copies data from excel to a .txt file . I can successfully copy the data into the .txt file but I am having two issues.
1. Is there a way that the code opens the .txt workbook in notepad ++ rather than notepad
2. I am trying to add a filename and save the .txt file but the code I have is not working, I copied some code that works for excel in naming and saving documents but it is not working for the txt file.
Any help is greatly appreciated.
Code below
VBA Code:
Sub CopytoNotepad()
Dim fName As String
Dim wbDest As Workbook
Sheets("POL").Select
Range("A4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Shell "notepad.exe", vbNormalFocus
SendKeys "^V"
SendKeys "^{HOME}"
fName = "EXL4.YT.LR.YTJAPAPF.F025.A.D" & Format(Date, "yymmdd") & ".P.F" & ".txt"
fName = Application.GetSaveAsFilename(FileFilter:="*.txt (*.txt), *.txt", Title:="Save As")
If fName = "" Then Exit Sub
End Sub