求助!关于痕迹保留的问题?
各位大虾,我想问一下与office软件无缝集成的文档管理和文件修改痕迹保留,是怎么实现的?主要是痕迹保留是怎样实现的?谢谢了。 问题点数:0、回复次数:3Top
1 楼csouth(金子)回复于 2003-04-01 14:13:32 得分 0
解决方案(一):
步骤:
1、用vb做一个activex控件,里面要包含microsoft internet transfer control 6.0控
件和command控件
2、microsoft internet transfer control 6.0用于文档的上传和下载、command用于激
活程序。
3、以下是部分代码:
Private Sub command1_Click()
Dim hSearch As Long ' 搜索句柄变量
Dim WFD As WIN32_FIND_DATA
Const forreading = 1
Const tristateusedefault = -2
Dim Cont As Integer
Cont = True
hSearch = FindFirstFile("c:\server.spp", WFD) '查找指定文件
If hSearch <> INVALID_HANDLE_VALUE Then
Cont = FindClose(hSearch)
Dim filescript, filename, ts
Set filescript = CreateObject("scripting.filesystemobject")
Set filestr = filescript.getfile("c:\server.spp")
Set ts = filestr.openastextstream(forreading, tristateusedrefault)
If Not (ts.AtEndOfStream) Then
servernamestr = ts.readline
End If
If Not (ts.AtEndOfStream) Then
filenamestr = ts.readline
End If
If Not (ts.AtEndOfStream) Then
ftppassword = ts.readline
End If
If Not (ts.AtEndOfStream) Then
ftpusername = ts.readline
End If
If Not (ts.AtEndOfStream) Then
usernamestr = ts.readline
End If
lensum = Len(ftpusername)
i = 1
shname:
Char = InStr(i, ftpusername, "#")
If Char <> 0 Then
shleft = Left(ftpusername, Char - 1)
i = Char - 1
ftpusername = Right(ftpusername, Len(ftpusername) - Char)
ftpusername = ftpusername & Chr(shleft / 5)
GoTo shname
End If
lensum = Len(ftppassword)
i = 1
'解密
shpassword:
Char = InStr(i, ftppassword, "#")
If Char <> 0 Then
shleft = Left(ftppassword, Char - 1)
i = Char - 1
ftppassword = Right(ftppassword, Len(ftppassword) - Char)
ftppassword = ftppassword & Chr(shleft / 5)
GoTo shpassword
End If
'初始化ftp服务器
Inet1.URL = "ftp://" + ftpusername + ":" + ftppassword + "@" + servernamestr
Inet1.Protocol = icFTP
Inet1.RemoteHost = servernamestr
Inet1.RemotePort = 21
Inet1.Password = ftppassword
Inet1.UserName = ftpusername
'得到系统的临时目录
Dim tempdir As String * 255
Dim sh As String
x = GetTempPath(255, tempdir)
tmpdir = Left(tempdir, x)
tmpdir = Trim(tmpdir) + filenamestr
hSearch = FindFirstFile(tmpdir, WFD) '查找系统临时目录中指定文件
If hSearch <> INVALID_HANDLE_VALUE Then
Cont = FindClose(hSearch)
Dim fs, f1
Set fs = CreateObject("scripting.filesystemobject")
Set f1 = fs.getfile(tmpdir)
f1.Delete
End If
Inet1.Execute "ftp://" + ftpusername + ":" + ftppassword + "@" + servernames
tr, "get " + filenamestr + tmpdir
Dim obj As Object
Set obj = CreateObject("Word.Application")
obj.Visible = True
obj.documents.open (tmpdir)
Else
MsgBox "在系统中找不到server.spp文件,请重新刷新页面,再试一次!", 0, "警
告"
End If
End Sub
这段代码主要是将服务器上的doc下载到本地的windows临时目录。
其中server.spp文件为系统自动生成,内容为ftp的用户名、口令、当前用户中文名等组
成,也可通过html传参数的形式替换该文件。
以上代码仅供参考!
回复人: briany(飞翔) (2002-1-8 18:09:06)
(适合CS模式)创建库表
创建一个新数据库和一个新表单,在表单中创建一个RTF域,取名为“Body”。Lotus 的
RTF域可以嵌入并显示OLE对象,此“Body”域用来创建一个Word对象。接着创建三个操
作按钮分别取名为“拟正文”、“隐藏痕迹”和“查看痕迹”。
代码实现。
下面是实现修改痕迹保留的具体代码。
1.“拟正文”操作按钮功能及实现代码如下:
实现在“Body”域中创建一个Word(OLE)对象,用来存储文档的正文。
Sub Click(Source As Button)
Dim session As New NotesSession
Dim workspace As New NotesUI- Workspace
Dim uidoc As NotesUIDocument
Set uidoc=workspace.CurrentDocument
Dim doc As NotesDocument
Set doc=uidoc.Document
user = session.commonUserName
uidoc.gotofield("Body")
If (doc.HasEmbedded) Then
Set rtitem=doc.GetFirstItem("Body")
Set embed=rtitem.EmbeddedObjects(0)
Set OLEObject=uidoc.GetObject(embed.name)
Else
'在当前文档的Body域中创建一个新的、空白的Microsoft Word对象,对象名为Microso
ft Word 文档,对象类型为Word.Document.8
Set OLEObject=uidoc.CreateObject("MicrosoftWord 文档","Word.Document.8","")
Call uidoc.save
End If
With OLEObject
.TrackRevisions = True
'保留修改痕迹
.PrintRevisions = True
'打印修改痕迹
.ShowRevisions = True
'显示修改痕迹
.Application.UserName=Session.CommonUserName
End With
End Sub
2
2.“隐藏痕迹”操作按钮功能及实现代码如下:
Sub Click(Source As Button)
Dim session As New NotesSession
Dim ws As New Notesuiworkspace
Dim uidoc As Notesuidocument
Dim doc As Notesdocument
Set uidoc=ws.currentdocument
Set doc=uidoc.document
If (doc.HasEmbedded) Then
Set rtitem=doc.GetFirstItem("Body")
Set embed=rtitem.EmbeddedObjects(0)
Set OLEObject=uidoc.GetObject(embed.name)
With OLEObject
.TrackRevisions =True
.PrintRevisions = False
.ShowRevisions = False
.Application.UserName=Session.CommonUserName
End With
End If
End Sub
隐藏修改痕迹,即不显示,但仍可保留修改痕迹,一般在打印正式文件时使用。
3.“查看痕迹”操作按钮功能及实现代码如下:
Sub Click(Source As Button)
Dim session As New NotesSession
Dim ws As New Notesuiworkspace
Dim uidoc As Notesuidocument
Dim doc As Notesdocument
Set uidoc=ws.currentdocument
Set doc=uidoc.document
If (doc.HasEmbedded) Then
Set rtitem=doc.GetFirstItem("Body")
Set embed=rtitem.EmbeddedObjects(0)
Set OLEObject=uidoc.GetObject(embed.name)
With OLEObject
.TrackRevisions =True
.PrintRevisions = False
.ShowRevisions = False
.Application.UserName=Session.CommonUserName
End With
End If
End Sub
通过以上步骤,就可以实现文档修改痕迹的保留的基本功能,以上程序在Lotus Notes
R5上测试通过,希望对感兴趣的读者能提供一定的帮助。
Top
2 楼kele1012(可乐)回复于 2003-04-01 14:40:04 得分 0
谢谢了。请问能在b/s模式下用这代码吗?Top
3 楼kele1012(可乐)回复于 2003-04-01 15:34:00 得分 0
谢谢了。能把在b/s下全部代码都给我吗?我真的很急用,因为我现在在搞毕业设计,遇到这问题。
拜托了高手!Top




