![]() |
|
#1
|
|||
|
|||
![]()
Could a script be written to remember the last view the user had when editing a CDR file?
For example, I had zoomed in on a part of an org chart and saved the file. The next time I or someone else opened that file, I'd like the drawing-display to look the same as when I last exited that file. Xara does this automatically and it is very useful. It would be great if something similar were in CorelDRAW when collaborating with others over our intranet .... especially those who are neophytes using Draw. Regards, John |
#2
|
||||
|
||||
![]()
This should be possible. But I haven't gotten it to work yet, was wondering if someone else in the group could tell me what I am doing wrong. Here is my code:
Code:
Private Sub GlobalMacroStorage_DocumentOpen(ByVal Doc As Document, ByVal FileName As String) If CheckLastView("LastView") = True Then Doc.Views("LastView").Activate End Sub Private Sub GlobalMacroStorage_DocumentBeforeSave(ByVal Doc As Document, ByVal SaveAs As Boolean, ByVal FileName As String) If CheckLastView("LastView") = True Then Doc.Views("LastView").Delete Doc.Views.AddActiveView "LastView" End Sub Private Function CheckLastView(VwName As String) As Boolean Dim Vw As View For Each Vw In ActiveDocument.Views If Vw.Name = VwName Then CheckLastView = True Exit For End If Next Vw Set Vw = Nothing End Function Thanks, Shelby |
#4
|
||||
|
||||
![]()
Here's correct code:
Code:
Private Sub GlobalMacroStorage_DocumentOpen(ByVal doc As Document, ByVal FileName As String) Dim p As Page If doc.Properties.Exists("LastView", 0) Then Set p = doc.Pages(doc.Properties("LastView", 0)) If Not p Is Nothing Then p.Activate doc.ActiveWindow.ActiveView.SetViewPoint _ doc.Properties("LastView", 1), doc.Properties("LastView", 2), _ doc.Properties("LastView", 3) End If End Sub Private Sub GlobalMacroStorage_DocumentBeforeSave(ByVal doc As Document, ByVal SaveAs As Boolean, ByVal FileName As String) With ActiveWindow.ActiveView doc.Properties("LastView", 0) = doc.ActivePage.Index doc.Properties("LastView", 1) = .OriginX doc.Properties("LastView", 2) = .OriginY doc.Properties("LastView", 3) = .Zoom End With End Sub doc.Views saving doesn't work - CorelDraw bug/intended behaviour For CorelDraw12, which doesn't have .exists property you need to use this Code:
Private Sub GlobalMacroStorage_DocumentOpen(ByVal doc As Document, ByVal FileName As String) Dim p As Page If doc.Properties("LastView", 0) <> 0 Then Set p = doc.Pages(doc.Properties("LastView", 0)) If Not p Is Nothing Then p.Activate doc.ActiveWindow.ActiveView.SetViewPoint _ doc.Properties("LastView", 1), doc.Properties("LastView", 2), _ doc.Properties("LastView", 3) End If End Sub Private Sub GlobalMacroStorage_DocumentBeforeSave(ByVal doc As Document, ByVal SaveAs As Boolean, ByVal FileName As String) With ActiveWindow.ActiveView doc.Properties("LastView", 0) = doc.ActivePage.Index doc.Properties("LastView", 1) = .OriginX doc.Properties("LastView", 2) = .OriginY doc.Properties("LastView", 3) = .Zoom End With End Sub Last edited by wOxxOm; 02-05-2006 at 10:08. |
#5
|
||||
|
||||
![]()
That is a great workaround! Wish I would have thought of it. LOL. Anyway, JCS(John) here is a GMS of the finished code. It does what you asked. Just drop it into your GMS dir and you should be good to go. I have only test this in CorelDRAW X3.
Thanks, Shelby |
#6
|
|||
|
|||
![]() ![]() ![]() Thanks. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
NEED HELP ON CORELDRAW SCRIPT. FREE PHOTO CALENDAR IF U CAN! | johnlfitz | CorelDRAW/Corel DESIGNER VBA | 8 | 06-06-2008 22:59 |
Turning on color calibration in a Corel Script | Alien2001 | CorelDRAW CS | 2 | 13-07-2005 23:34 |
VB script to save JPG (photopaint12) | tonywong | Corel Photo-Paint VBA | 2 | 17-05-2005 08:27 |
problem with script or macro. | Dr Morpheus | CorelDRAW/Corel DESIGNER VBA | 1 | 12-02-2004 13:46 |
Cropmarks script | Peter | Macros/Add-ons | 0 | 06-11-2003 03:51 |