【发布时间】:2021-12-04 03:42:51
【问题描述】:
我在互联网上找到了一个宏,它将 Word 文档中的选择保存为新文档。
Sub SaveSelectedTextToNewDocument()
If Selection.Words.Count > 0 Then
'Copy the selected text
Selection.Copy
'Open a new document and paste the copied text into it
Dim objNewDoc As Document
Set objNewDoc = Documents.Add
Selection.Paste
'Get the first 10 characters as the filename of the new document and save them
Dim objFileName As Range
Set objFileName = objNewDoc.Range(Start:=0, End:=10)
objNewDoc.SaveAs FileName:="C:\Users\Test\Desktop\" & objFileName & ".docx"
Else
End If
End Sub
我不想将文件名的文件保存为文档的前 10 个字母。我希望文件名的数量增加(例如 1.docx、2.docx、3.docx 等)。
【问题讨论】:
-
所以您希望 Word 在您使用宏时记住两次之间的最后一个数字?