Page 1 of 1

VBScript format pages

Posted: Wed Feb 03, 2016 1:42 pm
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

Re: VBScript format pages

Posted: Wed Feb 03, 2016 5:16 pm
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?

Re: VBScript format pages

Posted: Wed Feb 03, 2016 7:35 pm
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.

Re: VBScript format pages

Posted: Wed Feb 03, 2016 9:52 pm
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