H
hans
Hi,
I need some help with this one:
I'd like to open a word document (testdocument.doc); adjust it and save
the document again as result.doc . I wrote the following code to
perform this action, but if I run the application, I get an error:
Microsoft Word error '800a1066'
Command failed
/pro2006/test-word.asp, line 47
Can somebody tell me what I'm doing wrong?
(I'm using office 2003 and the code is written in ASP.)
Dim sTemplateFile
Dim sTargetFile
Dim oWordApp ' Our Word application
Dim oWordDoc ' Our Word document
'File system object
Dim oFSO
sTemplateFile = Server.MapPath("\pro2006") & "\testdocument.doc"
sTargetFile = Server.MapPath("\pro2006") & "\result.doc"
'Delete old target file
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists(sTargetFile) Then oFSO.DeleteFile(sTargetFile)
Set oFSO = Nothing
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<%
'Create an instance of Word Application
set oWordApp = Server.CreateObject("Word.Application")
'Open template
set oWordDoc = oWordApp.Documents.Open(sTemplateFile) '(=> this is
line 47)
oWordApp.visible = false
oWordApp.DisplayAlerts = false
'Save document
oWordApp.ActiveDocument.SaveAs sTargetFile
'Quit Word
set oWordDoc = Nothing
oWordApp.Quit
set oWordApp = Nothing
I need some help with this one:
I'd like to open a word document (testdocument.doc); adjust it and save
the document again as result.doc . I wrote the following code to
perform this action, but if I run the application, I get an error:
Microsoft Word error '800a1066'
Command failed
/pro2006/test-word.asp, line 47
Can somebody tell me what I'm doing wrong?
(I'm using office 2003 and the code is written in ASP.)
Dim sTemplateFile
Dim sTargetFile
Dim oWordApp ' Our Word application
Dim oWordDoc ' Our Word document
'File system object
Dim oFSO
sTemplateFile = Server.MapPath("\pro2006") & "\testdocument.doc"
sTargetFile = Server.MapPath("\pro2006") & "\result.doc"
'Delete old target file
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists(sTargetFile) Then oFSO.DeleteFile(sTargetFile)
Set oFSO = Nothing
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<%
'Create an instance of Word Application
set oWordApp = Server.CreateObject("Word.Application")
'Open template
set oWordDoc = oWordApp.Documents.Open(sTemplateFile) '(=> this is
line 47)
oWordApp.visible = false
oWordApp.DisplayAlerts = false
'Save document
oWordApp.ActiveDocument.SaveAs sTargetFile
'Quit Word
set oWordDoc = Nothing
oWordApp.Quit
set oWordApp = Nothing