2009年6月12日 星期五

與LotesNotes建立Openoffice空白文件「直向」轉換為「橫向」作法

//==============================
透過Lotus Notes 建立OpenOffice並將文件由
「直向」轉換為「橫向」。
//==============================

Sub Click(Source As Button)
Dim objServiceManager As Variant
Dim objDesktop As Variant
Dim objDocument As Variant

Dim sURL As String
Dim session As New NotesSession
Dim db As NotesDatabase
Dim args() As Variant
Dim argsEnd() As Variant

Dim objCursor As Variant
Dim objText As Variant
Dim PageStyles As Variant
Dim StdPage 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 PageStyles=objDocument.StyleFamilies.getByName("PageStyles")
Set objText = objDocument.getText()
Set objCursor = objText.createTextCursor()
objCursor.gotoStart(False)

Set StdPage= PageStyles.getByName(objCursor.PageStyleName)
StdPage.IsLandscape=True
StdPage.Width=29700
StdPage.Height=21000
End Sub

沒有留言: