新建一个word文档,然后打开之后,出现file in use, test.doc is locked for edit...
我新建一个word文档,然后打开之后,出现file in use, test.doc is locked for edit...的一个对话框,为什么不能直接打开呢?代码:
Set oWordApp = CreateObject("Word.Application")
oWordApp.Visible=Ture
Set oWordDoc = oWordApp.Documents.Add
oWordDoc.SaveAs "C:\Unified Functional Testing\Word\test.doc"
EditWordtext "C:\Unified Functional Testing\Word\test.doc","Step1: check input value is right"
Function EditWordtext (filepath,content)
Set WordApp=CreateObject("Word.Application")
WordApp.Visible=True
Set doc=WordApp.Documents.Open(filepath)
doc.content=content
doc.Save
Set doc=Nothing
Set WordApp=Nothing
ReadWord=True
End Function
运行时,test.doc 文档已经创建。
当走到Set doc=WordApp.Documents.Open(filepath) 这步时,就会出现一个对话框选择,而不是直接打开,我是win7的系统。
自己顶一下! 不了解,帮顶。。。 之前有没有打开过?打开了是不是就不能编辑了 EditWordtext "C:\Unified Functional Testing\Results\Test.doc","Step1: check input value is right"
Function EditWordtext (filepath,content)
Set fso = CreateObject("Scripting.FileSystemObject")
Set oWord = CreateObject("Word.Application")
Set WshShell = CreateObject("WScript.Shell")
oWord.displayAlerts=false
oWord.visible=False
If not (fso.FileExists(filepath)) Then
Set oWordDoc=oWord.Documents.Add
oWordDoc.SaveAs filepath
End If
Set oWordDoc=GetObject(filepath)
oWord.documents.open filepath,ForAppending,True
Set oDoc=oWord.ActiveDocument
Set oRange=oDoc.content
oRange.insertafter content
WshShell.SendKeys"{ENTER}"
wait(1)
oWord.ActiveDocument.Save
oWord.Application.Quit True
Set oRange=Nothing
Set oDoc=Nothing
Set oWord=Nothing
End Function
一样的问题,运行到save那步的时候,不能直接保存要另存到某处。显示文件是read only的
要崩溃了。怎么弄呀
页:
[1]