如何使用macros打开和保存notepad.exe

我是编程新手,所以我来这里寻求帮助。

我需要从Excel中复制文本字段并将其粘贴到记事本中,然后将具有特定名称的记事本保存到特定位置。 这些事情应该在macros的帮助下完成。

任何帮助将不胜感激

我能够从Excel复制文本并粘贴在记事本中,不知道如何将其保存在新的位置

sub Macro2() Range("A5").Select Selection.Copy Shell "notepad.exe", vbMaximizedFocus SendKeys "^V" End Sub 

你真的需要记事本吗?

你为什么不保存文本文件并打开它? SendKeys有点不可预知…

 Sub Macro2() Dim f As Integer 'get a free file handle f = FreeFile 'open test.txt in temp dir for writing Open Environ("TEMP") & "\test.txt" For Output As f 'write text from cell A5 Print #f, Range("A5").Text 'close file handle Close #f 'open file with notepad Shell "NOTEPAD.EXE " & Environ("TEMP") & "\test.txt" End Sub