我无法从 Excel 宏 (Office XP) 打开 Word。如果我使用此代码,它将停止在线Set wdDoc = wordapp.Documents.Open(polozka.ShortPath)
并且程序冻结。如果我使用Set wdDoc = GetObject(polozka.ShortPath)
而不是这一行,程序会在此处停止With wdDoc.Selection
并出现错误:
“对象不支持此属性”
Dim wordapp As Word.Application
Dim wdDoc As Word.Document
Set fso = CreateObject("Scripting.FileSystemObject")
Set files = fso.GetFolder("C:\path").Files
Set wordapp = CreateObject("Word.Application")
For Each polozka In files
Set wdDoc = wordapp.Documents.Open(polozka.ShortPath)
wordapp.Visible = True
With wdDoc.Selection
.HomeKey Unit:=6
.Find.Text = "Název (typ):"
.Find.Wrap = wdFindContinue
...
End With
...
wordapp.Quit
Set wordapp = Nothing
Next