怎么没有人回答得我的问题啊?急!!"word.application"

klmswt 2002-05-16 05:16:41
各位帮帮忙嘛!!!

我要在asp中操作word
为什么执行
set objword=createobject("word.application")会出错
...全文
42 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
klmswt 2002-05-17
  • 打赏
  • 举报
回复
谢谢lzlibk(贝壳)
我先研究研究,希望能解决我的问题。
一定高分致谢!!
sduwjr 2002-05-17
  • 打赏
  • 举报
回复
共同学习
nickycheng 2002-05-17
  • 打赏
  • 举报
回复
学习学习
lzlibk 2002-05-16
  • 打赏
  • 举报
回复
下面是我曾经把access的数据从服务器端写到客户端的word
文件模板里,模板定义了many书签对应数据库里的内容!
注意:浏览器的activex要启用,权限放到最大
实例:
<%@language=vbscript%>
<%
set cn = server.createobject("adodb.connection")
cnstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("testdoc.mdb") & ";Mode=ReadWrite|Share Deny None;Persist Security Info=True"
cn.open cnstr
set rs = cn.execute("select * from doc1")

response.contenttype = "Text/HTML"

response.write "<html>" & chr(13)
response.write "<head><title>一个简单页面</title>" & chr(13)
response.write "<SCRIPT LANGUAGE=" &chr(34) & "VBScript" & chr(34) & ">" & chr(13)
response.write "<!--" & chr(13)

response.write "sub Button1_OnClick" & chr(13)
response.write space(4) & "set MyWord = createobject(" & chr(34) & "Word.Application" & chr(34) & ")" & chr(13)
response.write space(4) & "MyWord.Application.Documents.Open " & chr(34) & "C:\gwcl\公文.doc" & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.GoTo -1,,, " & chr(34) & "发文字" & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.TypeText " & chr(34) & rs("fwz") & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.GoTo -1,,, " & chr(34) & "发文号" & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.TypeText " & chr(34) & rs("fwh") & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.GoTo -1,,, " & chr(34) & "标题" & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.TypeText " & chr(34) & rs("bt") & chr(34) & chr(13)

response.write space(4) & "tmpstr = " & chr(34) & chr(34) & chr(13)

str = rs("zw")
flag = 0

i = instr( str , chr(13) )
j = instr( str , chr(34) )
k = len( str )

if i < j and i > 0 then
flag = 1
end if
if i < j and i = 0 then
flag = 2
end if
if j < i and j > 0 then
flag = 2
end if
if j < i and j = 0 then
flag = 1
end if


do while flag <> 0
response.write space(4) & "tmpstr = tmpstr + "
select case flag
case 1
s1 = mid(str,1,i-1)
str = mid(str, i+1, k-i)
case 2
s1 = mid(str,1,j-1)
str = mid(str, j+1, k-j)
end select
response.write chr(34) & s1 & chr(34) & chr(13)

flag = 0

i = instr( str , chr(13) )
j = instr( str , chr(34) )
k = len( str )

if i < j and i > 0 then
flag = 1
end if
if i < j and i = 0 then
flag = 2
end if
if j < i and j > 0 then
flag = 2
end if
if j < i and j = 0 then
flag = 1
end if

loop

response.write space(4) & "tmpstr = tmpstr + " & chr(34) + str & chr(34) & chr(13)

response.write space(4) & "MyWord.ActiveWindow.Selection.GoTo -1,,, " & chr(34) & "正文" & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.TypeText tmpstr" & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.GoTo -1,,, " & chr(34) & "成文日期" & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.TypeText " & chr(34) & rs("cwrq") & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.GoTo -1,,, " & chr(34) & "主题词" & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.TypeText " & chr(34) & rs("ztc") & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.GoTo -1,,, " & chr(34) & "发文单位" & chr(34) & chr(13)
response.write space(4) & "tmpstr = " & chr(34) & rs("fwdw") & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.TypeText tmpstr & space(48-len(tmpstr)*2)" & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.GoTo -1,,, " & chr(34) & "签发人" & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.TypeText " & chr(34) & rs("qfr") & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.GoTo -1,,, " & chr(34) & "打字人" & chr(34) & chr(13)
response.write space(4) & "tmpstr = " & chr(34) & rs("dzr") & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.TypeText tmpstr & space(23-len(tmpstr)*2)" & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.GoTo -1,,, " & chr(34) & "校对人" & chr(34) & chr(13)
response.write space(4) & "tmpstr = " & chr(34) & rs("jdr") & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.TypeText tmpstr & space(24-len(tmpstr)*2)" & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.GoTo -1,,, " & chr(34) & "印数" & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveWindow.Selection.TypeText " & chr(34) & rs("ys") & chr(34) & chr(13)

'DEBUG BEGIN
'response.write space(4) & "Application.Visible = True"
'response.write space(4) & "MyWord.ActiveDocument.PrintOut"
'DEBUG END

'DEBUG SWITCH

'DEBUG BEGIN
response.write space(4) & "Path2File = " & chr(34) & "C:\gwcl\公文" & chr(34) & " & Year(Date) & Month(Date) & Day(Date) & Hour(Time) & Minute(Time) & Second(Time) & " & chr(34) & ".doc" & chr(34) & chr(13)
response.write space(4) & "MyWord.ActiveDocument.SaveAs Path2File" & chr(13)
'DEBUG END

response.write space(4) & "MyWord.quit" & chr(13)
response.write space(4) & "set MyWord = Nothing" & chr(13)
response.write "end sub" & chr(13)

response.write "-->" & chr(13)
response.write "</SCRIPT>" & chr(13)

response.write "</head>" & chr(13)
response.write "<body>" & chr(13)
response.write "<H3>一个简单页面</H3>" & chr(13)
response.write "<HR>" & chr(13)
response.write "<form><input name=" & chr(34) & "Button1" & chr(34) & " type=" & chr(34) & "BUTTON" & chr(34) & " value=" & chr(34) & "点击" & chr(34) & ">" & chr(13)
response.write "</form>" & chr(13)
response.write "</body>" & chr(13)
response.write "</html>" & chr(13)

rs.close
set rs = nothing
cn.close
set cn = nothing
%>
julyclyde 2002-05-16
  • 打赏
  • 举报
回复
nickycheng(垃圾):你才不清呢!当然可以用!




既然是意外嘛……那就没什么好说的了
nickycheng 2002-05-16
  • 打赏
  • 举报
回复
服务端怎么可以用set objword=createobject("word.application")?
你的概念似乎有点模糊不清
klmswt 2002-05-16
  • 打赏
  • 举报
回复
nickycheng老弟, 你说对了,就是只有"错误"
nickycheng 2002-05-16
  • 打赏
  • 举报
回复
天哪~错误详细报告....
不会你执行页面什么都没说,就写了“错误“两个字吧?
klmswt 2002-05-16
  • 打赏
  • 举报
回复
上面把application 写成document了,不过
把word.application 改成word.document出现的是一样的错误.
klmswt 2002-05-16
  • 打赏
  • 举报
回复

<%
set objWordDoc =server.CreateObject("Word.document") '就是显示这一行代码所在的行出现错误呀!
ObjWordDoc.Application.Documents.Add buildDoc.dot, False
ObjWordDoc.Application.Visible=True
%>
nickycheng 2002-05-16
  • 打赏
  • 举报
回复
具体什么错误提示啊?要我们自己猜哦?
klmswt 2002-05-16
  • 打赏
  • 举报
回复
aduwjr(流星)同志:
set objword=server.createobject("word.application")
执行不正确的,它会显示
错误类型:
服务器对象, ASP 0177 (0x80010105)
服务器出现意外情况。
sduwjr 2002-05-16
  • 打赏
  • 举报
回复
set objword=server.createobject("word.application")

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧