我要实现的是修改留痕功能,我希望修改后的文档基础上,自动再生成一个没有痕迹的文档。也就是说,修改一次,就多出一份文档,并且该文档,我可以定义名字。
我希望用在notes里面用代码的形式来加载word中的动作。也就是说,我在designer中写代码,要求word给出动作---比如实现新建,拷贝,及接受修订等动作。
希望可以给出一个大概的想法代码或是例子!!!
vba
如果是C/S也可采用ole
Sub Click(Source As Button)
Dim s As New notessession
Dim todaydate As New notesdatetime("Today")
Dim word As Variant
Dim wordoc As Variant
Dim todaysdate As String
Dim orderid As String
Dim producedby As String
Dim storeid As String
Dim customername As String
Dim address As String
Dim citytown As String
Dim postcode As String
Dim daytimeno As String
Dim eveningno As String
Predefined values: (replace with field values from uidoc)
todaysdate = todaydate.localtime
orderid = "2183763248"
producedby = s.username
storeid = "12345"
customername = "John Doe"
address = "Apartment 5c, 5 Test Avenue"
citytown = "Testtown"
postcode = "XX5 5XX"
daytimeno = "1234567890"
eveningno = "0987654321"
Create the Word object:
Set word = CreateObject("Word.Application") Create Word object
Call word.documents.add("C:\Documents and Settings\user\My Documents\Return and Uplift.dot") Create a new document based on the template "Return and Uplift.Dot"
Set worddoc = word.activedocument Get a handle for the active document
Assign the field values:
worddoc.FormFields(1).result = todaysdate
worddoc.FormFields(2).result = orderid
worddoc.FormFields(3).result = producedby
worddoc.FormFields(4).result = storeid
worddoc.FormFields(5).result = customername
worddoc.FormFields(6).result = address
worddoc.FormFields(7).result = citytown
worddoc.FormFields(8).result = postcode
worddoc.FormFields(9).result = daytimeno
worddoc.FormFields(10).result = eveningno
worddoc.saveas(customername) save the document with the filename of "John Doe.doc"
word.visible = True Comment this line if you dont want to show Word.
word.quit remove comment if you want to close rather than show Word.
End Sub
这样会不会!
是用VBA编程吧
关注
当然是商业秘密,至少在我们公司是这样的,可以跟你透露
是在word中用vba实现的
不要用ole了
会使系统不稳定的
直接操作附件吧
就像邮件中的附件一样,把一个文件附加到某个RTF域保存,而不是使用OLE对象的形式,同时利用lotusscript和VBA,打开这个附件并进行操作,早把它重新保存的RTF域里
第一你创建Word对象后将Application隐藏后执行代码就可以
第二你可以自己建一个Com封装一下[将word9.olb导入就可以了.]
Set word = CreateObject("Word.Application") Create Word object
Call word.documents.add("C:\Documents and Settings\user\My Documents\Return and Uplift.dot") Create a new document based on the template "Return and Uplift.Dot"
Set worddoc = word.activedocument Get a handle for the active document
这写有了就可以
worddoc.Content.Copy
worddoc.Content.Paste
worddoc.saveas了.
如果不是就用我第二中方法,我在B/S模式下是可以实现的.