Your first way of attempting to open the existing document is bound to fail,
since it uses the
VBA parameter scheme (the := thing), which is NOT
supported in VBScript. Why the second one fails is beyond me, but the last
looks promising - at least it gets thorugh to Word and has that program
attempt to open the file. I think your problem is that you use c:test.doc,
which tells the filesystem to search for test.doc in the CURRENT (read:
current for the executing process) directory. If it's located in the root of
the c: drive, you should use c:\test.doc instead.
Hope this helps,
- Allan
Quote:
>I have 2 problems invoking word from VBscript.
>1. I cannot get Word to appear on the screen. I know Word has been
>invoked by viewing NT task manager, but it does not appear despite a
visible
>statement. Here is my code:
>set objWD = CreateObject("Word.Application.8")
>objWd.Visible = true
>2. I cannot open an existing document. Here are 3 examples of different
>ways I've tried to open documents & the resulting error messages. I've
>tried a variety of document names that I know exist. I've also tried
>running this code in VB & all 3 examples work fine.
>Dim DocName
>DocName = "c:test.doc"
>set objWdDoc = objWD.Documents.Open(FileName:=DocName)
>Microsoft VBScript compilation error '800a03ee'
>Expected ')'
>---------------------------------------------------------------------------
-
>------
>Dim DocName
>DocName = "c:test.doc"
>set objWdDoc = objWD.Documents.Open(DocName)
>Microsoft VBScript runtime error '800a000d'
>Type mismatch: 'objWD.Documents.Open'
>---------------------------------------------------------------------------
-
>------
>set objWdDoc = objWD.Documents.Open("c:test.doc")
>Microsoft Word error '800a1436'
>This file could not be found. Try one or more of the following: * Check the
>spelling of the name of the document. * Try a different file name.
>(C:TEST.DOC)