Code: Select all
Set objServiceManager= WScript.CreateObject("com.sun.star.ServiceManager")
Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")
Set objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
Userkey = CreateObject("WScript.Shell").RegRead("HKEY_CURRENT_USER\Volatile Environment\FullName")
Modtager = "E.N. Modtager"
Gade = "Gaden 1444"
By = "9999 Voresby"
'*******************************************
Dim args()
Set objDoc= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
Set oFrame = objDoc.createInstance( "com.sun.star.text.TextFrame" )
Set oViewCursor = objDoc.CurrentController.getViewCursor()
oPageStyleName = oViewCursor.PageStyleName
Set oPageStyles = objDoc.StyleFamilies.getByName("PageStyles")
Set oStyle = oPageStyles.getByName(oPageStyleName)
Set objText= objDoc.getText
Set objCursor= objText.createTextCursor
objText.insertString objCursor, "Kære " & Modtager & vbLf & vbLf & vbLf & vbLf & "m.v.h. " & Userkey , false
oStyle.TopMargin = 10000
oStyle.RightMargin = 5000
oStyle.BottomMargin = 1200
oStyle.FooterIsOn = False
oStyle.HeaderIsOn = False
oFrame.Width = 8000
objDoc.Text.insertTextContent objDoc.Text, oFrame, false
oFrame.AnchorType = AS_CHARACTER
oFrame.IsFollowingTextFlow = False
oFrame.HoriOrient = 0
oFrame.VertOrient = 0
oFrame.TopMargin = 0
oFrame.VertOrientPosition = -7000
oFrame.HoriOrientPosition = 0
Set oFrameCursor = oFrame.createTextCursor()
oFrameCursor.String = Modtager & Vbcr & Gade & Vbcr & By
oFrameCursor.CharHeight="16"
oFrameCursor.CharFontName="Trebuchet MS"
oViewCursor.GoUp 3, False