[英]“the command is not available because no document is open” - MS Word 2010 VBA Error from Lotus Notes
我有一些VBA代码,这些代码在Lotus Notes 8.5.2中执行,可基于MS Word 2003模板创建MS Word文档。 这对于Word 2003、2007和2010而言对我来说很好用。但是,使用MS Word 2010的一位客户遇到了错误MS Word: the command is not available because no document is open
该行MS Word: the command is not available because no document is open
:
Set wdObject = createObject("word.Application")
wdObject.Documents.Add( wordpath & "\" & docname )
wdObject.ActiveDocument.Builtindocumentproperties(wdPropertyTitle) = sTemplateName
为什么使用Word 2010的一位用户而不是我的一位用户会发生此错误? 她有Windows 7,未配置文件夹重定向。
您可能需要这样编码:
On Error Goto CreateNewInstance
Set msWord = GetObject("", "Word.Application")
Done:
Set CreateMSWordDocument = msWord
Exit Function
CreateNewInstance:
Print "Loading Microsoft Word.... Please Wait...."
Err = 0
Set msWord = CreateObject("Word.Application")
Print "Microsoft Word Loaded"
Resume Done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.