Set a zoom size for a sheet in Calc

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Manikandan
Posts: 44
Joined: Tue Jun 21, 2011 11:40 am

Set a zoom size for a sheet in Calc

Post 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
Openoffice.org 2.3, Windows XP
User avatar
Zizi64
Volunteer
Posts: 11494
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: set a zoom size for a sheet in calc

Post 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.)
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Manikandan
Posts: 44
Joined: Tue Jun 21, 2011 11:40 am

Re: set a zoom size for a sheet in calc

Post by Manikandan »

Hi Zizi64,

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

Any other help please ?

Regards,

Manikandan.
Openoffice.org 2.3, Windows XP
User avatar
Zizi64
Volunteer
Posts: 11494
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: set a zoom size for a sheet in calc

Post 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...)
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Manikandan
Posts: 44
Joined: Tue Jun 21, 2011 11:40 am

Re: set a zoom size for a sheet in calc

Post by Manikandan »

Hi Zizi64,
I am using open office 2.3. I am not able find this option "Synchronize Sheets".

Regards,

Manikandan
Openoffice.org 2.3, Windows XP
User avatar
Zizi64
Volunteer
Posts: 11494
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: set a zoom size for a sheet in calc

Post 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
Last edited by Zizi64 on Mon Aug 22, 2011 1:12 pm, edited 1 time in total.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11494
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: set a zoom size for a sheet in calc

Post by Zizi64 »

Synchronize_sheets.png
Picture from my OxygenOffice3.2.1
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Manikandan
Posts: 44
Joined: Tue Jun 21, 2011 11:40 am

Re: set a zoom size for a sheet in calc

Post 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
Openoffice.org 2.3, Windows XP
User avatar
Zizi64
Volunteer
Posts: 11494
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: set a zoom size for a sheet in calc

Post 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 320 times
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Manikandan
Posts: 44
Joined: Tue Jun 21, 2011 11:40 am

Re: set a zoom size for a sheet in calc

Post 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
Openoffice.org 2.3, Windows XP
User avatar
Zizi64
Volunteer
Posts: 11494
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: set a zoom size for a sheet in calc

Post 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/
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Manikandan
Posts: 44
Joined: Tue Jun 21, 2011 11:40 am

Re: set a zoom size for a sheet in calc

Post by Manikandan »

Hi zizi64,

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

Manikandan
Attachments
Create_a_simple_calc_file.rar
Example file
(1.82 KiB) Downloaded 217 times
Openoffice.org 2.3, Windows XP
User avatar
Zizi64
Volunteer
Posts: 11494
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: set a zoom size for a sheet in calc

Post 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...
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: set a zoom size for a sheet in calc

Post 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.
Bernard

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