|
本帖最后由 shenzhenyang 于 2024-8-26 12:02 编辑
- Sub 复制到新的文本()
- Application.ScreenUpdating = False
- Dim ws As Worksheet
- Set ws = ThisWorkbook.Sheets("Sheet1")
- fname = ActiveWorkbook.Name
-
- Dim cellValue As String
- cellValue = ws.Range("A1").Value
-
- Dim filePath As String
- filePath = "D:\Desktop\newfile.txt" ' 修改为你的文件路径和文件名
-
- Dim fnum As Integer
- fnum = FreeFile()
- Open filePath For Output As #fnum
- Print #fnum, cellValue
- Close #fnum
- Shell "notepad.exe " & filePath, vbNormalFocus
- ' 选择文本文件内容
- ' SendKeys "^a", True ' 使用SendKeys选中全部内容
- ' SendKeys "^c", True ' 复制到剪切板
- ' SendKeys "%{F4}", True '关闭txt文件
-
-
- Application.ScreenUpdating = True
- End Sub
复制代码 上面代码是复制A1 单元格到新的文本,然后全选文本内容,复制剪切板,在全选文本内容复制到剪切板过程运行很慢,老师能怎么样才能运行更快。谢谢 |
|