Page 1 of 1

Set a zoom size for a sheet in Calc

Posted: Sat Aug 20, 2011 8:41 am
by Manikandan
Dear all,

I use the following code to set a zoom size for a calc document using visual basic application.

Code: Select all

Dim oController As Object
Set oController = oDoc.getCurrentController()
oController.ZoomType = 3
oController.ZoomValue = 75
It sets the zoom size for the whole document. But, I want to set only for a specified sheet.

Any help would be appreciated.

Regards,

Manikandan

Re: set a zoom size for a sheet in calc

Posted: Sat Aug 20, 2011 9:19 am
by Zizi64
Hi,

See:

http://www.oooforum.org/forum/viewtopic.phtml?t=115896
Maybe it will help you.

(The Basic language of OOo is not VISUAL BASIC, or VBA. It is OOBasic, StarBasic or simple: Basic.)

Re: set a zoom size for a sheet in calc

Posted: Sat Aug 20, 2011 9:37 am
by Manikandan
Hi Zizi64,

I need to set it by code. it looks like manual settings.

Any other help please ?

Regards,

Manikandan.

Re: set a zoom size for a sheet in calc

Posted: Sat Aug 20, 2011 9:49 am
by Zizi64
it looks like manual settings.
Yes, it is; but only the "Synchronize sheets" option needed set up (Turn OFF) manually once... Then you can to set the zoom factor for a specified sheet (only).

or try this:

Code: Select all

sub zoom2
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Zoom.Value"
args1(0).Value = 75
args1(1).Name = "Zoom.ValueSet"
args1(1).Value = 28703
args1(2).Name = "Zoom.Type"
args1(2).Value = 0

dispatcher.executeDispatch(document, ".uno:Zoom", "", 0, args1())
end sub
It works for me (after uncheck the "Synchronize sheets" option manually...)

Re: set a zoom size for a sheet in calc

Posted: Mon Aug 22, 2011 12:34 pm
by Manikandan
Hi Zizi64,
I am using open office 2.3. I am not able find this option "Synchronize Sheets".

Regards,

Manikandan

Re: set a zoom size for a sheet in calc

Posted: Mon Aug 22, 2011 12:54 pm
by Zizi64
I am using open office 2.3. I am not able find this option "Synchronize Sheets".
It is a very, very, very old version.

You need update to LibreOffice3.3.4 or 3.4.2 or: to OpenOffice3.3.x

Re: set a zoom size for a sheet in calc

Posted: Mon Aug 22, 2011 1:07 pm
by Zizi64
Synchronize_sheets.png
Picture from my OxygenOffice3.2.1

Re: set a zoom size for a sheet in calc

Posted: Thu Aug 25, 2011 1:50 pm
by Manikandan
Hi Zizi64,

I installed the open office version Open office 3.4 . It installed succesffuly. I can work in the application manually. when i tried to use application by vb code, it raises an error on the following code

Code: Select all

Set oSM = CreateObject("com.sun.star.ServiceManager")
the error message say"Can not create an activex component object".

Could you please advise why it occurs and what needs to be done.

Regards,

Manikandan

Re: set a zoom size for a sheet in calc

Posted: Thu Aug 25, 2011 5:13 pm
by Zizi64
I installed the open office version Open office 3.4 . It installed succesffuly. I can work in the application manually.
Please update your signature, too.

Dear all,
I use the following code to set a zoom size for a calc document using visual basic application.
when i tried to use application by vb code, it raises an error on the following code
Code: Select all Expand view
Set oSM = CreateObject("com.sun.star.ServiceManager")
the error message say"Can not create an activex component object".
Please attach all lines of the your OOBasic code.
((The MS VBA and OOBasic are not compatible. You can not save OOBasic code into an MS .xls file, and the MS VBA will not work perfectly in Openoffice.))

I use the following code to set a zoom size for a calc document using visual basic application.
Do you using the native ODF (.ods for Calc) filetype?


The previous attached (recorded by the macrorecorder) subroutine (named: "zoom2" ) was worked for you in an .ods file? See the attached file:
Zoom1_2.ods
(9.9 KiB) Downloaded 338 times

Re: set a zoom size for a sheet in calc

Posted: Fri Aug 26, 2011 6:12 am
by Manikandan
Hi ,
The same code works for openoffice 2.3 version, but, it does not work for openoffice 3.4 only. what my problem is, I completed the vb application to export the data to openoffice . It works successfully for open office 2.3. some points does not work. ie. zoom size option only for specified sheet .For this reason, you advised me to update the latest open office version. So, I installed open office 3.4. But, it does not work at the starting point.ie. creating a object for the open office.

Regards,

Manikandan

Re: set a zoom size for a sheet in calc

Posted: Fri Aug 26, 2011 6:54 am
by Zizi64
Can you upload your example file (include the macros) here ?
(We can check it, and I can try it on my LibreOffice)

For this reason, you advised me to update the latest open office version. So, I installed open office 3.4. But, it does not work at the starting point.ie. creating a object for the open office.
If I know exactly, there is no stable version of OpenOffce3.4, it is a Beta version, today.
http://download.openoffice.org/index.html
The latest stable is the OpenOffice3.3.x.
But There is LibreOffice3.4.2 stable version or there is LibreOffice3.3.4 (more stable version)
http://www.libreoffice.org/download/

Re: set a zoom size for a sheet in calc

Posted: Sat Aug 27, 2011 7:28 am
by Manikandan
Hi zizi64,

I am uploading the example vb file herewith for your reference.

Manikandan

Re: set a zoom size for a sheet in calc

Posted: Sat Aug 27, 2011 10:43 am
by Zizi64
I am uploading the example vb file herewith for your reference.
OOoops!
I understand now: it is a standalone Visual Basic application, but it is not "some macro routines/functions located inside the ods/xls file".
Sorry, I can not help you...

Re: set a zoom size for a sheet in calc

Posted: Tue Aug 30, 2011 3:15 pm
by B Marcelly
Hi,
I suppose you have incorrect Windows registry data for OpenOffice COM Automation, after you have updated from 2.3 to 3.4. You should uninstall, clean Windows registry and OpenOffice folders, then re-install.

But as already said, OOo 3.4 is not stable, and COM-Automation is bugged in OOo 3.3 and LibreOffice 3.4.2.
And OpenOffice.org development is stalled for some months.

So I think there is currently no solution to your problem.