Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

"Fit To Zoom Window " Issue while opening document .

Hi Guys ,

I am facing alot of problem while diplaying the document.

I have document with total 9 sheets alongwith 1 "Welcome" Sheet .

I incorporated a buttom with "FitZoomTo Window & ApplyZoomToAllSheets " macro on welcome page , so that OnClick my "Welcome Page" will Fit To Window as well as all other sheets will be align as per Welcome Page.

Below is the Code:

/*



Sub

rem ** fit active sheet to window and apply same zoom to all sheets **

ActiveDocument.ActiveSheet.FitZoomToWindow

ActiveDocument.ActiveSheet.ApplyZoomToAllSheets









End

End

Sub ZoomWindow

End







*/

Now my problem is that everytime i open my document , i need to adjust my "Welcome" to "Fit to Window" using Menu options & After that i need to Click Button to apply for all sheets.

I also tried to put my Macro (which i used in Button) in "Document Properties ---> Triggers ---> Document Event Triggers ---> OnOpen" . But it didn't serve my purpose.

Can anybody guide me for the same ???

Thanks,



Bhushan N

7 Replies
Not applicable
Author

Hi

I'm not entirely sure what your problem is, but I guess that what you want is for this macro to run automatically when you open the document.

Just a warning for you, I have this FitZoomToWindow function in all of my applications and I have now removed any automatic running of the macro, I did this because often the users would get a very small window where the zoom had not worked properly, they would then have to shut it down and start again, sometimes they would have to do this several times before it would give them a useable window.

This is a recognised bug with QlikTech and in the last 12 months since reporting it, they have not solved the problem.

My advice would be to stick with providing a manual button for the zoom function and let the users push that each time, the alternative is not useable.

Not applicable
Author

Hi Nigel,

Thanks for your reply , you replied exactly what i need . I will try to get some help from Qliktech.

Meantime i have one query for you . Using above macro i can't able to resize my current sheet to "FitToWindow" . Everytime i need to go in View / Menu to do the same.

So can you please advice me on how to get macro enabled button to that after clicking the same , my sheet will resize itself to window size.

Thanks,

Bhushan N

Not applicable
Author

Hi Bhushan

Apologies if I got the message wrong but as I understand it, you are struggling to create the button itself and link it to a macro.

1. Create the button

2. Go to properties of the button

3. Add some text (Zoom to fit for example)

4. Change the Function (bottom of the General tab) to Macro

5. Go to the Macro tab

6. Select your zoom macro name from the drop down list

NOTE: The above instructions are based on version 8.50, if you are using version 9.0 then it is a little different because you have actions, in this case follow steps 1 to 3 above, then.....

4. Go to the Actions tab

5. Click on the Add button, select External, select Run Macro

6. Select your macro

There you go.....

Not applicable
Author

Hi Nigel ,

Thanks for your guidance , I am able to implement "Fit to Window" for all sheets as well as "OnOpen" document successfully.

I achieved this using Macro enabled Button.

Thanks a lot again .

Not applicable
Author

Hey bnirgude,

Could you please give me the code from the macro you're using?

We're currently building an application and fit to all windows would be a nice feature.

Thanks in advance,

Sajjad_M

Not applicable
Author

Hello Sajjad

The code is actually in the opening part of this thread, very simple really:

SUB FitZoomToWindow

ActiveDocument.ActiveSheet.FitZoomToWindow

ActiveDocument.ActiveSheet.ApplyZoomToAllSheets

END SUB

Regards,

blaise
Partner - Specialist
Partner - Specialist

The following macro does a ZoomFactor check, and if is is below .5 or above 2 the zoom is reset to 100 %. If the ZoomFactor falls inside the segment it is applied to all sheets. This can be a way to make sure the zoom never gets to small. You can of couse loop the macro aswell (and hope that Qv will find the correct zoom after a few tries) BUT BE SURE TO ADD A COUNTER, so the sub is ended after a few unsuccessfull tries.



sub ZoomWithErrorCheck
set doc = ActiveDocument
set aSheet = doc.ActiveSheet
aSheet.FitZoomToWindow
doc.GetApplication.WaitForIdle
set asProp=aSheet.GetProperties
'msgbox(asProp.ZoomFactor)
if asProp.ZoomFactor < 0.5 or asProp.ZoomFactor > 2 then
asProp.ZoomFactor = 1
aSheet.SetProperties asProp
else
aSheet.ApplyZoomToAllSheets
end if
end sub