Word from an ASP 
Author Message
 Word from an ASP

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)



Sun, 22 Jul 2001 03:00:00 GMT  
 Word from an ASP
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)



Sun, 22 Jul 2001 03:00:00 GMT  
 Word from an ASP
1) I have no idea why this wouldn't work -- that works just fine on my
machine.

2) VBScript doesn't support the ":=" syntax for named arguments -- you need
to pass all the arguments in the correct order as defined in the
documentation for the Open method.

Eric


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)



Sun, 22 Jul 2001 03:00:00 GMT  
 Word from an ASP
I resolved my own problem - but for anyone else out there who may have the
same problem here's what I discovered:

1.    objWd.Visible = true     worked once I moved it to a client side
script block

2.    set objWdDoc = objWD.Documents.Open(DocName) works if DocName is the
actual document name (excluding any path).  If the document to be opened is
not in the default directory, the following line of code is required prior
to the .open statement:

objWd.ChangeFileOpenDirectory "C:\"



Sun, 22 Jul 2001 03:00:00 GMT  
 Word from an ASP
Oh, you were trying to start word on the _server_?  That's never going to
work -- the web server is not allowed to create applications that have user
interfaces.  (Suppose you were serving a hundred pages a second -- would you
want a hundred copies of Word to start up per second?  I think not.)

Eric


Quote:
> I resolved my own problem - but for anyone else out there who may have the
> same problem here's what I discovered:

> 1.    objWd.Visible = true     worked once I moved it to a client side
> script block

> 2.    set objWdDoc = objWD.Documents.Open(DocName) works if DocName is the
> actual document name (excluding any path).  If the document to be opened
is
> not in the default directory, the following line of code is required prior
> to the .open statement:

> objWd.ChangeFileOpenDirectory "C:\"



Sun, 22 Jul 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Invoking Word from IE/ASP code, I get ActiveX Security Problems

2. Really stuck on creating a WOrd document from ASP

3. Opening WORD from an ASP page...

4. Opening WORD from an ASP page...

5. Start word document from ASP page.

6. Opening and Writing to Word Document From ASP.NET,C# application

7. Opening Word Document using ASP

8. Word-related IE/ASP/ActiveX/Createobject Problems

9. problems creating a word.application in ASP

10. Passing word object to ASP from vb dll

11. Opening Word Document using ASP

12. Word Automation from ASP Component

 

 
Powered by phpBB® Forum Software