问题
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