Hello,
I've been using the following code to save over the original notepad file after it has been modified in excel. I would like to do the same with .xls file. How do I change this code to suit my needs?
Thanks,
Lenna
I've been using the following code to save over the original notepad file after it has been modified in excel. I would like to do the same with .xls file. How do I change this code to suit my needs?
Thanks,
Lenna
Code:
Dim myPath As String
' original filename & path
myPath = Application.ActiveWorkbook.FullName
' Selects & copies trimmed data range, _
assuming starts in A1 with no blank rows b4 last row
Range("A:E").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
' Turns off error prompt window b4 closing temp excel worksheet _
(to allow Notepad to save revisions over original filename) _
then reactivates error prompt window
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
' Reopens original unmodified files in notepad from same original filename & path _
then selects all to paste modified version over it, resaves it with original filename & path _
& closes it via Alt + F4
Shell "notepad.exe """ & myPath & """", vbNormalFocus
SendKeys "^a"
SendKeys "^v"
SendKeys "^s"
SendKeys "%{f4}"