透過Lotus Notes按鈕建立一份空白文件,並且在文件上建立表格
建立表格後,在插入列,便於未來的表格應用。
//--------------------------------------------------------------
Sub Click(Source As Button)
Dim objServiceManager As Variant
Dim objDesktop As Variant
Dim objDocument As Variant
Dim objTable As Variant
Dim objCursor As Variant
Dim objRows As Variant
Dim objRow As Variant
Dim objCellCursor As Variant
Dim objCellText As Variant
Dim sURL As String
Dim session As New NotesSession
Dim db As NotesDatabase
Dim args() As Variant
Dim argsEnd() As Variant
' Initialize the OpenOffice Environment
Set objServiceManager = CreateObject("com.sun.star.ServiceManager")
Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
' Initialize the Lotus Notes Environment
Set db = session.CurrentDatabase
' URL to create a new file
sUrl ="private:factory/swriter"
Set objDocument = objDesktop.loadComponentFromURL(sURL, "_blank", 0, args)
Set objText= objDocument.getText()
Set objCursor= objText.createTextCursor()
'建立表格
Set objTable= objDocument.createInstance( "com.sun.star.text.TextTable")
建立2列4欄的表格
objTable.initialize 2, 4
'Insert the table
objText.insertTextContent objCursor, objTable, False
'Get first row
Set objRows= objTable.getRows()
Set objRow= objRows.getByIndex(0)
'將第一欄填入名稱
Set objCellText= objTable.getCellByName("A1")
Set objCellCursor= objCellText.createTextCursor()
objCellCursor.setPropertyValue "CharColor",255
objCellText.insertString objCellCursor, "第一欄", False
'插入6列,使表格變成8列4欄
objRows.insertByIndex objRows.getCount(), 6
End Sub
參考網站:http://api.openoffice.org/docs/common/ref/com/sun/star/table/XTableRows.html#insertByIndex
沒有留言:
張貼留言