Excel-Integration in cobol

i was able to find the correct syntax for many functions giving in msexcel.cpy

But not to set the topmargin, bottommargin, leftmargin, right margin

in VB the syntax found is

Worksheets("Sheet1").PageSetup.LeftMargin = _ Application.CentimetersToPoints(2)

The function for this in msexcel.cpy are:
*> Method: "getMarginBottom".
*> 01 MarginBottom comp-1.
*> invoke returning MarginBottom.
*> ----------------
*> Method: "setMarginBottom".
*> 01 MarginBottom comp-1.
*> invoke using
*> by value MarginBottom *> [IN].
*> ----------------
*> Method: "getMarginLeft".
*> 01 MarginLeft comp-1.
*> invoke returning MarginLeft.
*> ----------------
*> Method: "setMarginLeft".
*> 01 MarginLeft comp-1.
*> invoke using
*> by value MarginLeft *> [IN].
*> ----------------
*> Method: "getMarginRight".
*> 01 MarginRight comp-1.
*> invoke returning MarginRight.
*> ----------------
*> Method: "setMarginRight".
*> 01 MarginRight comp-1.
*> invoke using
*> by value MarginRight *> [IN].
*> ----------------
*> Method: "getMarginTop".
*> 01 MarginTop comp-1.
*> invoke returning MarginTop.
*> ----------------
*> Method: "setMarginTop".
*> 01 MarginTop comp-1.
*> invoke using
*> by value MarginTop *> [IN].

But all my tries are not successfull
May be in newer office version any invoke must be set otherwise

I can only hope that Chris know the solution!
Thanks for all help!

invoke Pagesetup "getMarginBottom" using ???


cg
Parents
  • 0  

    The following appears to be equivalent to the statement:

    Worksheets("Sheet1").PageSetup.LeftMargin = _ Application.CentimetersToPoints(2)

    *> Create a new instance of Microsoft Excel
    invoke MSExcel "new" returning ExcelObject

    *> Get the collection of WorkBooks
    invoke ExcelObject "getWorkBooks"
        returning WorkBooksCollection


    invoke WorkbooksCollection "Open" using ExcelFileName
        returning Workbook

    invoke Workbook "getWorksheets"
        returning worksheets

    invoke Worksheets "getItem" using z"Sheet1"
       returning worksheet1

    *> Points is defined as COMP-1

    invoke ExcelObject "CentimetersToPoints" using by value 2
       returning points

    invoke worksheet1 "getPageSetup"
       returning pagesetup

    invoke pagesetup "setLeftMargin" using by value points

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0 in reply to   

    my tests this evening with your code was not successull

    what means value 2

Reply Children
  • 0   in reply to 

    I assume it means that you are converting 2 centimeters to points and using that as your margin. You should replace that with whatever your application requires.

    I am just following the example you provided.

    The code I provided to you works for me and if I make Excel visible and look at the margins set for the worksheet they have a custom size and the left margin has been changed.

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button