VBScript format pages

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
hobbit1
Posts: 2
Joined: Wed Feb 03, 2016 1:33 pm

VBScript format pages

Post by hobbit1 »

I would like to help to translate the following code in VBScript:

Dim Doc As Object
Dim Sheet As Object
Dim StyleFamilies As Object
Dim PageStyles As Object
Dim DefPage As Object

Doc = ThisComponent
StyleFamilies = Doc.StyleFamilies
PageStyles = StyleFamilies.getByName("PageStyles")
DefPage = PageStyles.getByName("Default")

DefPage.LeftMargin = 1000
DefPage.RightMargin = 1000
OpenOffice 4.1.2 on Windows 7
User avatar
MTP
Volunteer
Posts: 1620
Joined: Mon Sep 10, 2012 7:31 pm
Location: Midwest USA

Re: VBScript format pages

Post by MTP »

Are you working with a Calc file or a Writer file?

Do you have to use VBScript and not, say, python?

Will the file you want to manipulate already be open, or will the script have to open it?

How will you identify the file you want to manipulate? By file url?
OpenOffice 4.1.1 on Windows 10, HSQLDB 1.8 split database
hobbit1
Posts: 2
Joined: Wed Feb 03, 2016 1:33 pm

Re: VBScript format pages

Post by hobbit1 »

I have to write a program in VBScript that manipulate CALC file.
I don't have problems opening the file.
I have problems to pass left margin, right margin, top margin and bottom margin of the page.
OpenOffice 4.1.2 on Windows 7
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: VBScript format pages

Post by B Marcelly »

Then it is simply:

Code: Select all

' ***** VBScript *****
Dim Doc
Dim Sheet
Dim StyleFamilies
Dim PageStyles
Dim DefPage

' ( you already have Doc )
Set StyleFamilies = Doc.StyleFamilies
Set PageStyles = StyleFamilies.getByName("PageStyles")
Set DefPage = PageStyles.getByName("Default")

DefPage.LeftMargin = 1000
DefPage.RightMargin = 1000
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Post Reply