如何解决根据excel电子表格中的条目在word中的照片下插入标题
我有一个用word编写的宏,用于将用excel编写的标题传输到word文档中的相应照片。目前它正在运行,但是我发现它随着时间的推移而变慢,它必须处理的字幕越多。因此,它最多可用于大约 200 张照片,但我需要它来处理 1000 多张照片。我相信这是因为我引用了 excel 工作簿而不是将数据传输到数组中,但是我无法成功实现将 excel 数据传输到数组中。任何帮助将不胜感激谢谢!
sub Cybernet2()
'Add excel object library tools>References
Dim intCount As Integer
Dim i As Integer
Dim doc As Word.Document
Dim path As String
Dim oex As Object
Dim exWb As Object
Dim ws As Object
Dim rng As Excel.Range
Dim rngsort As Excel.Range
Dim rw As Word.Range
Dim lr As Long
Dim xPic As Inlineshape
Application.ScreenUpdating = False
Application.displayStatusBar = False
Set oex = CreateObject("Excel.Application")
oex.Visible = False
path = ActiveDocument.ContentControls(2).Range.Text
Set exWb = oex.workbooks.Open(path,True)
Set ws = exWb.Worksheets(1)
'lr = ws.Cells(Rows.Count,"B").End(xlUp).Row
'Set rngsort = ws.Range(Cells(1,"b"),Cells(lr,"b"))
Set doc = ActiveDocument
For i = doc.Inlineshapes.Count To 1 Step -1
Set rw = doc.Inlineshapes(i).Range
doc.Inlineshapes(i).Select
Selection.InsertCaption "Photograph",":" & ws.Cells(i,"b").Value,"",wdCaptionPositionBelow,0
Next i
End Sub ```
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。