DsoFramer 微软的在线work控件有人用过吗?怎么定位到第几行第几列,急!附代码
DsoFramer 微软的在线work控件有人用过吗?我现在想在网页加载时自动往之前做好的word模板里加一些字,但是现在不知道怎么定位到第几行第几列,哪位高手知道指点一下,附代码:
<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="java.util.Map"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
<title>documentEdit</title>
<%
String basePath = request.getScheme()+"://"+request.getServerName()+"/";
System.out.println("basePath========="+basePath);
basePath = "http://www.ht.zjdtp.com/";
String filePath = basePath+"content/dav"+request.getSession().getAttribute("documentPath").toString();
System.out.println("filePath========="+filePath);
String con_code = "合同编码";
String con_name = "合同名称";
%>
<script language="VBScript">
Dim bDocOpen
Sub oframe_OnDocumentOpened(str, obj)
Dim s, s2
On Error Resume Next
bDocOpen = True
if len(str) = 0 then
str = "New Document"
else
Dim x
x = InStr(str, "\")
if x then
do
str = mid(str, x+1)
x = Instr(str, "\")
loop while x > 0
else
x = Instr(str, "/")
if x Then
do
str = mid(str, x+1)
x = Instr(str, "/")
loop while x > 0
end if
end if
end if
s = obj.Application.Name
End Sub
Sub oframe_OnDocumentClosed()
bDocOpen = False
End Sub
Sub OpenWebDoc(sUrl)
On Error Resume Next
If Len(sUrl) Then
document.all.oframe.Titlebar =false
document.all.oframe.open sUrl
document.oframe.EnableFileCommand(0)= FALSE
document.oframe.EnableFileCommand(1)= FALSE
document.oframe.EnableFileCommand(2)= True
document.oframe.EnableFileCommand(3)= True
if err.number then
MsgBox "无法打开文件 " & err.description
end if
End If
End Sub
Sub SaveWebDoc(sUrl)
On Error Resume Next
If Not bDocOpen Then
MsgBox "没有打开的文档."
Else
document.oframe.ActiveDocument.SaveAs sURL
MsgBox "操作成功"
End If
End Sub
Sub AcceptRevisions(pUrl)
if window.confirm("你确定要清稿吗?") then
On Error Resume Next
document.oframe.ActiveDocument.AcceptAllRevisions
document.oframe.WordBasic.AcceptChangesSelected
document.oframe.WordBasic.AcceptAllChangesInDoc
end if
End Sub
Sub unProtectDoc(pUrl)
MsgBox "取消保护状态"
document.oframe.ActiveDocument.Unprotect "xz"
End Sub
Sub InsertPic(imgUrl)
document.oframe.ActiveDocument.Shapes.AddPicture imgUrl,false,true,0,0,100,100,document.oframe.ActiveDocument.Application.Selection.Range
document.oframe.ActiveDocument.Shapes(1).ZOrder 4
End Sub
Sub ProtectDoc(pUrl)
MsgBox "保护状态"
document.oframe.ActiveDocument.Protect 1, True, "xz"
End Sub
Sub SaveChangeDoc(pUrl)
MsgBox "修订状态"
document.oframe.ActiveDocument.Protect 0, True, "xz"
End Sub
Sub ShowChangeDoc(pUrl)
document.oframe.ActiveDocument.ShowRevisions true
document.oframe.ActiveDocument.SaveAs pURL
End Sub
Sub PrintDoc()
On Error Resume Next
If Not bDocOpen Then
MsgBox "没有打开的文档."
Else
document.oframe.printout True
End If
End Sub
Sub CloseDoc()
On Error Resume Next
If Not bDocOpen Then
MsgBox "没有打开的文档."
Else
document.oframe.close
End If
End Sub
Sub Test_OnClick
Set doc = document.oframe.ActiveDocument
Set rngRange = doc.Range(0, 1)
//rngRange.InsertAfter " This is now the last sentence in paragraph one."
rngRange.InsertAfter "<%=con_code%>"
rngRange.InsertAfter "<%=con_name%>"
//Set paraCount = doc.Count
//MessageDlg(IntToStr(paraCount), mtInformation, [mbOK], 0)
//doc.Item(3).Range.InsertAfter("asdfaf")
End Sub
</script>
</head>
<body style="margin:0.0pt;" onload="OpenWebDoc('<%=filePath%>')">
<form name="docOnlineForm" method="post" action="UploadFile.jsp" enctype="multipart/form-data">
<table id="docTab" width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
<tr>
<td valign="top"></td>
<td valign="top" colspan="2" align="center">
<object classid="clsid:00460182-9E5E-11d5-B7C8-B8269041DD57" id="oframe" width="100%" height="650">
<param name="BorderStyle" value="1">
<param name="TitlebarColor" value="52479">
<param name="TitlebarTextColor" value="0">
<param name="Menubar" value="1">
</object>
</td>
</tr>
</table>
<input type="button" id="Test" value=" add " onclick="Test_OnClick();">
</form>
</body>
</html>