|
本帖最后由 weiyingde 于 2017-5-19 06:40 编辑
下面这个程序是将word转化为ppt的前奏,目的是将答案写入数组之中后删除原括号里的答案再将题目写入数组,为的是转换一步到位。
问题:第一题的括号中的答案不删除,导致转化后的ppt中答案保留在题干中。
请大侠帮助优化,word文档和转化后的问题课件如下。
Sub 将答案和题目分别写入数组后删除括号原答案()
Application.ScreenUpdating = False
Dim gs%, sr$, arr(), did$, brr(), mths, ii%
Dim Appt As New PowerPoint.Application
With CreateObject("vbscript.regexp")
.Global = True
.MultiLine = True
.Pattern = "[A-Z](?=\s*[/))])"
Set mths = .Execute(ActiveDocument.Content)
End With
For Each m In mths
ii = ii + 1
ReDim Preserve brr(1 To ii)
brr(ii) = m
Next
ActiveDocument.Content.Find.Execute "([\((])([A-D])([\))])", , , 1, , , , , , "" & " \1" & Space(8) & "\3" & "", 2
With ActiveDocument
wdnm$ = .Name
did$ = .Paragraphs(1).Range.Text
gs = (.Paragraphs.Count - 1) / 5
ReDim Preserve arr(1 To gs)
For i = 1 To gs
For y = (i - 1) * 5 + 2 To 5 * i + 1
sr = sr & .Paragraphs(y).Range.Text
Next
arr(i) = sr
sr = ""
Next
End With
ActiveDocument.Close savechanges:=wdSaveChanges
Word.Application.Quit
Application.ScreenUpdating = False
End Sub
附见如下。
|
|