VB Script Documents.Open throwing 424 error

陌路散爱 提交于 2019-12-19 10:19:50

问题


So I have a vbs script:

Function test2open( sSourceFile, sPDFFile )
  Dim wApp ' As Word.Application
  Dim wDoc ' As Word.Document

  logStream.writeline "inside test2open"
  on error resume next

  Set wApp = CreateObject("Word.Application")
  logStream.writeline Err.Number
  Err.Clear

  Set wDoc = wApp.Documents.Open("c:\Windows\Temp\test.DOC")
  logStream.writeline Err.Number
  logStream.writeline Err.Description
  logStream.writeline Err.Source

  wApp.Quit WdDoNotSaveChanges
  Set wApp = Nothing
End Function

I'm calling this vi php exec call through apache with cscript.exe. The point of the main script which I'm not going to paste the whole thing is to convert a word doc to a pdf. But both my full script and the one above have the same issue.

When I call the vbs script by itself while sitting on the windows box it works as I would think, but when called remotely through apache through php it errors on the Documents.Open call with 424 Error Object required Microsoft VBScript runtime error.

This same exact code is running correctly on 2 other windows boxes which makes me think this is some kind of permission issue (love those description MS error messages). But I cannot figure out what. Any thoughts?


回答1:


I believe I've found the answer to my question. The problem is that MS is restricting the use of automation of office products. Server 2008 64bit and office 2007 just don't work well. The solution that worked for me was found at:

http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91?prof=required

In case that thread disappears:

This solution is ...

・Windows 2008 Server x64

  Please make this folder.

  C:\Windows\SysWOW64\config\systemprofile\Desktop

・Windows 2008 Server x86

  Please make this folder.

  C:\Windows\System32\config\systemprofile\Desktop


来源:https://stackoverflow.com/questions/2105534/vb-script-documents-open-throwing-424-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!