|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
你不提供附件!!!,写一个代码给你:
Sub shishi()
Dim nstr$, bstr$, Myname$, d As Document
Set d = ActiveDocument
With d.Range(0, 0)
.MoveWhile " " & ChrW(160) & Chr(13) & Chr(11) & Chr(10)
.MoveEndUntil Chr(13): nstr = .Text: .Collapse 0
.MoveWhile " " & ChrW(160) & Chr(13) & Chr(11) & Chr(10)
.MoveEndUntil Chr(13): bstr = .Text
End With
Myname = GetName(nstr & bstr)
d.SaveAs d.Path & "\" & Myname & ".doc", wdFormatDocument
MsgBox "已另存到当前文档同目录下!"
End Sub
Function GetName(ByVal aStr As String) As String
Dim ErrArray() As Variant, oArray As Variant
ErrArray = Array("\", "/", "*", ":", "?", "<", ">", "|", """", Chr$(7), Chr$(8), Chr$(9), Chr$(10), Chr$(11), Chr$(13))
For Each oArray In ErrArray
aStr = Replace(aStr, oArray, "")
Next
GetName = LTrim(aStr)
End Function |
|