我需要将幻灯片从一个主卡座复制到另一个卡座。主甲板包含约150张幻灯片。每个主题都有2张幻灯片,并且有75个主题,每个主题名称都是唯一的。每张幻灯片的标题都包含主题名称,因此我要遍历标题,将找到匹配的标题复制到另一副卡片组。问题有时代码会丢失一张或两张幻灯片。绝对没有模式。如果我在相同的数据集上两次运行代码,将会有不同的幻灯片丢失。如果我多次运行它,我可能还会得到绝对完美的结果。
For iKI = intCountKISH To 3 Step -1 'iterating through the list of topics which are to be copied
strKIOSI = Trim(Workbooks(strActiveWorkbook).Worksheets(strTabITL).Cells(iKI, jCountSH)) ' picks up topic
If (strKIOSI <> Empty) Then 'if topic is not empty
For cntLib = countLibSlides To 1 Step -1 ' iterating through all the slides of master deck
titleText = Trim(libraryDeck.Slides(cntLib).Shapes("Title 1").TextFrame.TextRange.Text) 'reads title of slides in master deck
If (InStr(1, titleText, strKIOSI, 1) <> 0) Then ' if there is a match in titles for topic name
libraryDeck.Slides(cntLib).Copy 'copy the slide from master deck
pptDeck.Slides.Paste 5 'paste in the destination deck
Application.Wait (Now + TimeValue("00:00:01")) 'delay
End If
Next
End If
Next iKI
标题绝对没有错,因为在相同数据上重新运行代码可为我带来完美的结果。 我尝试增加延迟时间来完成粘贴操作,但这也无济于事。