LotusScript & MS WORD

The below code works very well to export a web view to a .doc file.     When exporting it takes the following format:

Colum1          column2         colume3
datadoc1 datadoc1 datadoc1
datadoc2 datadoc2 datadoc2
datadoc3 datadoc3 datadoc3

The export is being formatted as an html table. 

I've tried this many times, removing the table reference, setting borders to 0, viewing the source and keep encounter problems launching MS WORD and receive an unknown format error (w/word).  Like I said, it works perfectly to export a web view into a table in WORD, just dont want it exported into a table.  Information from this view is being used in a monthly report, which is bulleted and a very large reoirt. 

Perhaps another set of eyes might be able to see what I am missing.  Any help would be appreciated, I want to revise this code to the following format, removing the table and leaving it as just plain text.

Format needed:
datadoc1
datadoc1
datadoc1

datadoc2
datadoc2
datadoc2

datadoc3
datadoc3
datadoc3



The Script:

Dim session As New NotesSession
Dim db As NotesDatabase
Dim v As NotesView
Dim docX As NotesDocument
Dim col As Integer
Dim lineitem As String
Dim View As String
Dim Query_String As String
Dim Doc As NotesDocument
Dim Docs As NotesDocumentCollection
Dim ViewName As String
Dim Key As String
Dim Index1 As Integer
Dim Index2 As Integer

Set db = session.CurrentDatabase

Set Doc = session.DocumentContext
Query_String = Doc.Query_String(0)

Index1= Instr(Query_String, "View=")
If Index1 > 0 Then
Index1 = Index1 + Len("View=")
Index2 = Instr(Index1 + 1, Query_String, "&")
If Index2 > 0 Then
ViewName = Mid(Query_String, Index1, (Index2 - Index1))
Else
ViewName = Mid(Query_String, Index1, Len(Query_String) - Index1 + 1)
End If
End If

Print |Content-Type:application/vnd.ms-word|

Print |Content-Disposition:Attachment; filename="Report.doc"|

Set v = db.GetView(ViewName)

If Key <> "" And Key <> "*" Then
Set Docs = v.GetAllDocumentsByKey(Key, True)
End If
col=1
Print  |<Table border>|

lineitem=""
Forall vColumn In v.Columns              
If col=1 Then
lineitem=vColumn.Title
Else
lineitem=lineitem+vColumn.Title
End If
col=col+1
End Forall
lineitem=lineitem

Print lineitem

If True Then
Set docX=v.GetFirstDocument
lineitem=""
While Not docX Is Nothing
col=1
Forall cValue In docX.ColumnValues
If col=1 Then
lineitem=|<tr>|
End If
If cValue="" Then  
lineitem=lineitem+|<td>&nbsp;</td>|
Else   
lineitem=lineitem+|<td>|+cValue+|</td>|
End If
col=col+1
End Forall
Print lineitem+|</tr>|
Set docX=v.GetNextDocument(docX)
Wend
Print |</table>|

Else
Set docX=Docs.GetFirstDocument
lineitem=""
While Not docX Is Nothing
col=1
Forall cValue In docX.ColumnValues
If col=1 Then
lineitem=|<tr>|
End If
If cValue="" Then   
lineitem=lineitem+|<td>&nbsp;</td>|
Else   
lineitem=lineitem+|<td>|+cValue+|</td>|
End If
col=col+1
End Forall
Print lineitem+|</tr>|
Set docX=Docs.GetNextDocument(docX)
Wend
Print |</table>|
End If

Exit Sub
End Sub

转载于:https://www.cnblogs.com/hannover/archive/2012/04/17/2453397.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值