Vbscript VBS写入打开文件
我有一个word文档,用户可以输入数据。我有一个按钮,将运行VB来收集信息。我无法让VB在文档打开时将脚本的输出写入文档。VBS能否写入打开/活动的word文档?抱歉,如果这似乎是基本的…新的VB 您可以使用方法-设置对已打开Word文档的引用,如下代码所示:Vbscript VBS写入打开文件,vbscript,Vbscript,我有一个word文档,用户可以输入数据。我有一个按钮,将运行VB来收集信息。我无法让VB在文档打开时将脚本的输出写入文档。VBS能否写入打开/活动的word文档?抱歉,如果这似乎是基本的…新的VB 您可以使用方法-设置对已打开Word文档的引用,如下代码所示: Dim word, docs, docName, reqdDoc Set word = getObject(,"word.application") Set docs = word.documents docName = "Documen
Dim word, docs, docName, reqdDoc
Set word = getObject(,"word.application")
Set docs = word.documents
docName = "Document1" 'Enter the name of the document in which you want to write the data
'MsgBox docs.count
For Each doc In docs
If StrComp(doc.fullName,docName,1)=0 Then
Set reqdDoc = doc
Exit For
End If
Next
reqdDoc.Activate
word.selection.typeText "Hello There:"