|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 xiaoyouxi01 于 2018-2-27 22:39 编辑
暂时以楼主提供的附件,写了段简单代码,楼主可以自己试试~
- Sub 宏1()
- Dim path As String, filename As String, i As Integer
- For i = 1 To ActiveDocument.Paragraphs.Count
- If ActiveDocument.Paragraphs(i).Style = "标题 1" Then
- filename = filename & "&" & ActiveDocument.Paragraphs(i).Range
- End If
- Next i
- path = "C:"
- filename = Replace(Mid(filename, 2), vbCr, "")
- ActiveDocument.SaveAs2 filename:=path & filename & ".docx"
- End Sub
复制代码
贴在上面的这个代码,path = "C:\" 这句里的斜杠不知道怎么回事显示不出来。。再贴一个在下面~
Sub 宏1()
Dim path As String, filename As String, i As Integer
For i = 1 To ActiveDocument.Paragraphs.Count
If ActiveDocument.Paragraphs(i).Style = "标题 1" Then
filename = filename & "&" & ActiveDocument.Paragraphs(i).Range
End If
Next i
path = "C:\"
filename = Replace(Mid(filename, 2), vbCr, "")
ActiveDocument.SaveAs2 filename:=path & filename & ".docx"
End Sub
|
|