作者:乔山办公网日期:
返回目录:excel表格制作
首先,第三行是什么概念
是第三个段落?还是一个段落的第三行?你最好能发个图片上来
使用Find方法,看看是不是快了。
'样式、符合样式的当前段文本
Dim wdSty$, strTxt$
wdSty = "标题 1"
With Selection
.HomeKey unit:=wdStory, Extend:=wdMove'光标移到文档首
.Find.ClearFormatting
.Find.Style = ActiveDocument.Styles(wdSty)'设置查找文本的7a686964616fe4b893e5b19e363样式为wdSty(“标题1”)
End With
'循环查找文档里所有为“标题1”样式的段落,
Do While Selection.Find.Execute(findtext:="*^13", MatchWildcards:=True, Format:=True)
strTxt = Selection.Text '获取符合样式的文本
'.......在这里录入处理代码
Selection.Move unit:=wdWord, Count:=1
If Selection.MoveRight <> 1 Then'文档尾退出
Exit Do
Else
Selection.MoveLeft
End If
Loop
Sub AAA()
Dim FilePath As String '要读取的文件路径
Dim S1 As String '文档的内容
Dim S2 As String '提取到的内容
Dim Ar As Variant '用于保存最终结果
Dim L1 As Long '记录当前查找到的字符位置
FilePath = Application.GetSaveAsFilename(fileFilter:="Word文档,*.doc;*.docx")
If FilePath = "False" Then MsgBox "您没有选择文件,将退出程e68a84e79fa5e98193339序。": Exit Sub
With CreateObject("word.application")
With .Documents.Open(FilePath, True, True)
S1 = .Content
.Close False
End With
.Quit
End With
L1 = InStr(S1, "<") '第一个 < 位置
Do Until L1 = 0
If Len(S2) <> 0 Then
S2 = S2 & "Crazy0qwer" & Mid(S1, L1 + 1, InStr(L1, S1, ">") - L1 - 1)
Else
S2 = Mid(S1, L1 + 1, InStr(L1, S1, ">") - L1 - 1)
End If
L1 = InStr(L1 + 1, S1, "<")
Loop
Ar = Split(S2, "Crazy0qwer")
Range("A1").Resize(UBound(Ar) + 1) = Application.Transpose(Ar)
End Sub
一、设置标题格式
1、选中文章中的所有一级标题;百
2、单击开始选项度卡上的标题1,
仿照步骤1、2设置二、三级标题格式为标题2、标题3。知
二、自动生成目录
1、把光标放在到需要道生成目录的位置;
2、单击引用---->目录---->插入目录,
3、弹出目录对话框,选择目录选项卡,进行相关设版置后,单击“确定”按钮,文章的目录自动生成完成权。