What is Zoom to Selection Plus?
Zoom to Selection Plus is a macro that can zoom (change the view) in a variety of ways, and does so based on the current selection. It can:
From a user standpoint, ZTSP is only one command. What happens when it is used depends on what the current selection is - or, if nothing is selected, what visible objects are present on the page.For each of those types of zoom, to the rectangular area that bounds the selection, some "padding" can be added to the height and width. The amount of padding can be set by the user, as a percentage of the bounding dimension, with independent values for each of the types of zoom listed above. In addition to that padding, there is a user-settable "minimum view dimension", because one might not wish to zoom "all the way in" on very small selections.
There is also a "light" version that doesn't zoom in quite as many ways. It can:
The macro also includes a "Zoom to Page Plus" capability. The padding for that is user-settable, so the amount of white space around the page border can be smaller (or larger) than what CorelDRAW produces with its own "zoom to page".
Using the macro subs:
The capabilities described above are provided by simple macro subs that can be used as Commands in regular CorelDRAW workspace customization, so they can be used on toolbars or menus, and can have keyboard shortcuts assigned to them. The author assigns F4 to "Zoom to Selection Plus", Ctrl+F4 to "Zoom to Selection Plus Light", and Shift+F4 to "Zoom to Page Plus".
Managing settings:
A userform is used for managing the settings used by these subs.
ComboBoxes are used for the values that set the "padding" for different types of zoom carried out by ZTSP, and also for the value for the minimum view size. For adjusting and testing those values, there are buttons on the form for carrying out "Zoom to Selection Plus" and "Zoom to Page" plus.
If Show bounding rectangle is checked, then the macro draws an on-screen red rectangle to indicate the area that is being used as the basis for figuring out the view area. This is the area before adding anything for padding or to achieve the minimum view size, and it can be useful for understanding what's going on with ZTSPWhen zooming to selected objects, the macro uses the "true size" of objects (including outline width, corner styles, line caps, etc.) rather than "wireframe" size when determining the bounding rectangle.
Using the Comboboxes.
The boxes for numeric entry are comboboxes. The drop-down list for a combobox can contain values stored for convenient access. If a combobox is not locked, then when a value in thatcombobox is used by the macro, that value is added to the top of the list. If an existing value is used from the list, then that value is moved to the top of the list. Values can also be manually added to the list.
Ctrl+clicking on a combobox sets that combobox to its default value.
Right-clicking on a combobox brings up a menu of options for managing it.
These options may include:
Units of Distance.
For a combobox that represent a distance, values are applied by the macro in whatever units (inches, millimeters, etc.) are shown beside the combobox. Those units can be specified by the user through the right-click context menu.
If “Follow Horizontal Ruler Units” is chosen, then the units for the combobox are the same units that are in use in the document for the horizontal ruler. If those units are changed in the document, then the macro automatically changes the units in the combobox to match.
Although this documentation makes references to “the list” for the combobox, there is not necessarily only one list. The combobox maintains a separate list for any unit that is used in it. When units for the combobox are changed, then the list associated with those units is loaded. The number of decimal places, and also whether a list is locked or not, are things that are handled independently for each list.
A Video Describing and Demonstrating the Special Features of My ComboBoxes:
Zoom to Selection Plus subs in the Macro Manager.
The logic behind ZTSP.
For some insight into the logic used by ZTSP, see these flowcharts. These are links to PDF files, so you can follow them to see them as high-quality vector content:
Compatibility.
ZTSP was put together in a CorelDRAW X7 environment, and should work in versions X7-2020.
OK, where's the macro?
JQ_Zoom_to_Selection_Plus_Current.zip (most recently updated 2020-05-10).
That includes the .GMS file and a simple icon that can be used on a CorelDRAW Toolbar.
Please note that, starting with the version released on 2020-05-10, this macro uses a different scheme for storing combobox value lists and some preferences in the Registry. If you have been using an older version of this macro, those "old" value lists and preferences will not be there when you use the newer version. If you want to "clean out" those old entries that are not used by the newer version of the macro, the best way to do so is to run the Remove_ZTSP_Registry_Entries sub, which will set the macro back to its default values.
Awesome John! Thanks..
The idea is fantastic and approved by many of our followers. Congratulations for the work, simply amazing! Success for you always! ps: I will try the new version and update our readers soon.
I downloaded the new version and tested it, it is top, soon I will publish on the Site www.corelnaveia.com
Hey John. Thanks so much for this very helpful macro. There is a piece of it I'd like to use when I open a new document and zoom to fit the vertical part of the page. Is there an open source version of this macro or is there some code I could insert into the 'ThisMacroStorage' ?
There is a piece of it I'd like to use when I open a new document and zoom to fit the vertical part of the page.
CorelDRAW has its own "Zoom to Height" command. If you have the options for the Zoom tool configured to have right-clicking show a context menu, then you will see it there. (After all these years, the default workspace still has the right-click by default do a "zoom out", which to me is much less useful than the context menu.)
For at least some things - and I tried it with this one, with success - you can "invoke" the command in a VBA macro:
'invoke "Zoom to Height" commandApplication.FrameWork.Automation.InvokeItem "074d3aa0-c5f6-4326-bd85-c1fc43d8a459"
You can set that up to run automatically when a document is opened. If you want it in place for all documents, that might be in "ThisMacroStorage" for some project:
Private Sub GlobalMacroStorage_DocumentOpen(ByVal Doc As Document, ByVal FileName As String) 'invoke "Zoom to Height" command Application.FrameWork.Automation.InvokeItem "074d3aa0-c5f6-4326-bd85-c1fc43d8a459"End Sub
If you wanted to just build it into a specific document, then you could instead use it in "ThisDocument" in the project that is contained in that document:
Private Sub Document_Open() 'invoke "Zoom to Height" command Application.FrameWork.Automation.InvokeItem "074d3aa0-c5f6-4326-bd85-c1fc43d8a459"End Sub
Thank you so much! I will try this.
This works great. Now i'm trying to record a macro to zoom into a particular section of a new document. Here is the code and I get an error "object not defined'.
Windows.FindWindow("CorelDRAW 2019 (64-Bit) - 1/2"" = 1' Untitled-1 - Layer 1").ActiveView.ToFitArea 11.756335, 13.831055, 13.918772, 9.119516
Actually...I think I figured it out. YAY!
Now i'm trying to record a macro to zoom into a particular section of a new document.
If you aren't already familiar with it, you might look at this: #15 - Macro - "Saved View Areas".
If that would work for your application - zooming to a specific page view area that you had previously defined in the document - then I can show you a way that you can automatically run one of those subs when opening a document.
That way, you wouldn't need to "hard code" the area you wanted to view. It would just automatically zoom to whatever is currently stored in the document for, say, "Page View Area 1".