我在excel中有一段代码可以修改嵌入的word文档(显示为图标)并将其保存到路径中。 由于兼容性问题,我必须将其转换为后期绑定。我该怎么做?我需要改变什么? 这是我的代码的一部分,作为一个例子
Function Sport()
Dim wd As Word.Application
Dim doc As Word.Document
Dim ole As OLEObject
Dim EmbededFile As String
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet with the embedded file")
' Change to suit your needs, or build with code
EmbededFile = ThisWorkbook.path & "\Stuff.doc"
Set ole = ws.OLEObjects("Object")
ole.Activate
'ole.Verb Verb:=xlOpen
Set wd = ole.Object.Application
With wd.ActiveDocument
.SaveAs EmbededFile, Word.wdFormatDocumentDefault
.Close
End With
Set doc = wd.Documents.Open(EmbededFile)
'' do stuff
wd.Activate
doc.Close
wd.Quit
Sport = 3
End Function
提前感谢您的帮助