OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > CorelDRAW > Macros/Add-ons

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 21-04-2006, 14:39
JSC
Guest
 
Posts: n/a
Default Can a script "remember" the last view used?

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
Reply With Quote
  #2  
Old 24-04-2006, 01:43
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,791
Blog Entries: 15
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default View

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
The code creates the view on save as it should, but when you try and open the document you get a Run-time error. Per the X3 programming guide Doc.Views("LastView").Activate should work, but all I get is the error. I have tried in CorelDRAW 12 and X3 and get the same error. Ideas anyone?

Thanks,

Shelby
Reply With Quote
  #3  
Old 27-04-2006, 17:51
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,791
Blog Entries: 15
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Still not working

I have tried a couple of things, and still can't get it working. Alex any ideas what I am doing wrong? Thanks,

Shelby
Reply With Quote
  #4  
Old 27-04-2006, 18:40
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

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
it works.

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.
Reply With Quote
  #5  
Old 27-04-2006, 18:57
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,791
Blog Entries: 15
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Workaround

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
Attached Files
File Type: gms LastView.gms (17.5 KB, 563 views)
Reply With Quote
  #6  
Old 28-04-2006, 09:18
corel designer whiner
Guest
 
Posts: n/a
Unhappy Macro Schmacro!

Okay folks, this does not work in either v12 or v13. I don't know much about these here fancy scripty things, just try and fix it and let me know what the deal is.

Thanks.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
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


All times are GMT -5. The time now is 13:04.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com