|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 以文章题目为名保存文档()
- Dim myPG As Paragraph
- Dim Title, FullName As String, isBegin As Boolean
- Title = "": isBegin = False
- For Each myPG In ActiveDocument.Paragraphs
- With myPG.Range
- If .Font.Size = 22 Then
- isBegin = True
- Title = Title & Trim(Left(.Text, Len(.Text) - 1))
- ElseIf isBegin Then
- Exit For
- End If
- End With
- Next myPG
- If Len(Title) = 0 Then
- MsgBox "未获取到标题"
- Else
- FullName = ActiveDocument.FullName
- FullName = Left(FullName, InStrRev(FullName, "")) & _
- Left(Replace(Title, "?*:""<>\/|", ""), 255) & ".doc"
- 'Debug.Print FullName
- ActiveDocument.SaveAs2 FileName:=FullName, FileFormat:=wdFormatDocument
- End If
-
- End Sub
复制代码 |
|