Skip to main content

[archive] Need some help translating vb to cobol

  • February 14, 2007
  • 6 replies
  • 0 views

[Migrated content. Thread originally posted on 13 February 2007]

I want to adjust the pagesetup and set Zoom to false but I get a compiler error. When I set it to zero (Zoom = 0) then excel crashes.

Help me please.

With ActiveSheet.PageSetup
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1

modify olWrkSh @PageSetup::PaperSize = xlPaperA4,
@PageSetup::FitToPagesWide = 1,
@PageSetup::FitToPagesTall = 1,
@PageSetup::FirstPageNumber = xlAutomatic,
@PageSetup::Order = xlDownThenOver,
@PageSetup::Zoom = False.

* Zoom
PROPERTY-GET, 663, @Zoom
RETURNING "VARIANT", TYPE 12
* Zoom
PROPERTY-PUT, 663, @Zoom,
"VARIANT (Property Value)", TYPE 12

6 replies

[Migrated content. Thread originally posted on 13 February 2007]

I want to adjust the pagesetup and set Zoom to false but I get a compiler error. When I set it to zero (Zoom = 0) then excel crashes.

Help me please.

With ActiveSheet.PageSetup
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1

modify olWrkSh @PageSetup::PaperSize = xlPaperA4,
@PageSetup::FitToPagesWide = 1,
@PageSetup::FitToPagesTall = 1,
@PageSetup::FirstPageNumber = xlAutomatic,
@PageSetup::Order = xlDownThenOver,
@PageSetup::Zoom = False.

* Zoom
PROPERTY-GET, 663, @Zoom
RETURNING "VARIANT", TYPE 12
* Zoom
PROPERTY-PUT, 663, @Zoom,
"VARIANT (Property Value)", TYPE 12
Microsoft documentation states that the Zoom property may only bet set to a value between 10 and 400. If you do not want zoom, I suggest you do not set it, e.g. take it out. It is also stated that if the parent object is a chart, Zoom is not a valid property.

[Migrated content. Thread originally posted on 13 February 2007]

I want to adjust the pagesetup and set Zoom to false but I get a compiler error. When I set it to zero (Zoom = 0) then excel crashes.

Help me please.

With ActiveSheet.PageSetup
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1

modify olWrkSh @PageSetup::PaperSize = xlPaperA4,
@PageSetup::FitToPagesWide = 1,
@PageSetup::FitToPagesTall = 1,
@PageSetup::FirstPageNumber = xlAutomatic,
@PageSetup::Order = xlDownThenOver,
@PageSetup::Zoom = False.

* Zoom
PROPERTY-GET, 663, @Zoom
RETURNING "VARIANT", TYPE 12
* Zoom
PROPERTY-PUT, 663, @Zoom,
"VARIANT (Property Value)", TYPE 12
If I do not set Zoom then it is still selected in the pagesetup dialog and I want the field "adjust to" to be selected.

Andre

[Migrated content. Thread originally posted on 13 February 2007]

I want to adjust the pagesetup and set Zoom to false but I get a compiler error. When I set it to zero (Zoom = 0) then excel crashes.

Help me please.

With ActiveSheet.PageSetup
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1

modify olWrkSh @PageSetup::PaperSize = xlPaperA4,
@PageSetup::FitToPagesWide = 1,
@PageSetup::FitToPagesTall = 1,
@PageSetup::FirstPageNumber = xlAutomatic,
@PageSetup::Order = xlDownThenOver,
@PageSetup::Zoom = False.

* Zoom
PROPERTY-GET, 663, @Zoom
RETURNING "VARIANT", TYPE 12
* Zoom
PROPERTY-PUT, 663, @Zoom,
"VARIANT (Property Value)", TYPE 12
I found this article http://mail.python.org/pipermail/python-win32/2002-April/000337.html
However pywintypes can't be found in excel.def

Andre

[Migrated content. Thread originally posted on 13 February 2007]

I want to adjust the pagesetup and set Zoom to false but I get a compiler error. When I set it to zero (Zoom = 0) then excel crashes.

Help me please.

With ActiveSheet.PageSetup
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1

modify olWrkSh @PageSetup::PaperSize = xlPaperA4,
@PageSetup::FitToPagesWide = 1,
@PageSetup::FitToPagesTall = 1,
@PageSetup::FirstPageNumber = xlAutomatic,
@PageSetup::Order = xlDownThenOver,
@PageSetup::Zoom = False.

* Zoom
PROPERTY-GET, 663, @Zoom
RETURNING "VARIANT", TYPE 12
* Zoom
PROPERTY-PUT, 663, @Zoom,
"VARIANT (Property Value)", TYPE 12
Interesting, while seemingly irrational, there might be a rationale behind it. Languages that support the bool type will presumably distinguish between 0 and false, and for that matter true and 1, albeit we as human beings will consider it the same.
The difference is in that these are passed differently.
A 0 will typically be passed as a VT-I2, while a false will be passed as VT-BOOL.
The recepient (any correct programmed COM anyway) will before it attempts at the value of a variant, check the type. Say in this case then, it will check the type, see that it is a VT-I2 it will then look for a number in the aforementioned range. As in this case it is outside the range, and there are no error testing it runs into a mav.
On the contrary, if the COM type being passed was a VT-BOOL and this was detected, the zoom feature would be turned off rather than its value being used for a purpose it was not meant for.

So, try this:

modify olWrkSh @PageSetup::Zoom = 0 AS VT-BOOL

[Migrated content. Thread originally posted on 13 February 2007]

I want to adjust the pagesetup and set Zoom to false but I get a compiler error. When I set it to zero (Zoom = 0) then excel crashes.

Help me please.

With ActiveSheet.PageSetup
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1

modify olWrkSh @PageSetup::PaperSize = xlPaperA4,
@PageSetup::FitToPagesWide = 1,
@PageSetup::FitToPagesTall = 1,
@PageSetup::FirstPageNumber = xlAutomatic,
@PageSetup::Order = xlDownThenOver,
@PageSetup::Zoom = False.

* Zoom
PROPERTY-GET, 663, @Zoom
RETURNING "VARIANT", TYPE 12
* Zoom
PROPERTY-PUT, 663, @Zoom,
"VARIANT (Property Value)", TYPE 12
Yes it works. I created the field like this.
78 VT-BOOL VALUE 11.

I took the course but find it still difficult stuff but 'm learning all the time.

Thanks a lot.

[Migrated content. Thread originally posted on 13 February 2007]

I want to adjust the pagesetup and set Zoom to false but I get a compiler error. When I set it to zero (Zoom = 0) then excel crashes.

Help me please.

With ActiveSheet.PageSetup
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1

modify olWrkSh @PageSetup::PaperSize = xlPaperA4,
@PageSetup::FitToPagesWide = 1,
@PageSetup::FitToPagesTall = 1,
@PageSetup::FirstPageNumber = xlAutomatic,
@PageSetup::Order = xlDownThenOver,
@PageSetup::Zoom = False.

* Zoom
PROPERTY-GET, 663, @Zoom
RETURNING "VARIANT", TYPE 12
* Zoom
PROPERTY-PUT, 663, @Zoom,
"VARIANT (Property Value)", TYPE 12
Good work!

Btw, the variant constants (VT-BOOL etc) are defined in the standard def directory in the copy book activex.def.