OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 25-06-2007, 15:39
diwin
Guest
 
Posts: n/a
Default v11 code in v13

In CD v11, I wrote a procedure to open an existing template. When it opens it is, as usual, zoomed to the whole page. Yet when I move the .gms to another machine running v13, it opens zoomed to the maximum zoom level. One setting in the procedure sets the scale to 1:27,000. Because I don't have access to the v13 machine, I can't really troubleshoot it.

Any ideas?
Reply With Quote
  #2  
Old 25-06-2007, 15:41
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Daniel,

Can you show the code that does this?
Reply With Quote
  #3  
Old 25-06-2007, 18:44
diwin
Guest
 
Posts: n/a
Default

Thanks Alex.

Note: this is in a module under 'Modules' in the Project Explorer window. It is fired from a Toolbar Item.
Also, I can't figure out whether I need 'newDoc.RestoreSettings'.

Code:
Public Sub OpenMap()
On Error Resume Next
Optimization = True
EventsEnabled = False

Dim newDoc As Document
Dim lrNew As Layer
Dim pgSize As String
Dim s As shape
'On Error GoTo BailOut

Set newDoc = CreateDocumentFromTemplate("C:\My Documents\Map\MapTemplate.cdt")
'Set newDoc = CreateDocument()
Set newDoc = ActiveDocument
newDoc.SaveSettings
newDoc.PreserveSelection = False

newDoc.Unit = cdrKilometer
newDoc.Rulers.HUnits = cdrKilometer
newDoc.Rulers.VUnits = cdrKilometer

'newDoc.WorldScale = 39525150
'newDoc.WorldScale = 40000000
newDoc.WorldScale = 27000000

Set lrNew = ActivePage.CreateLayer("Dot Layer")
'ActivePage.Layers("Dot Layer").Activate	'Not needed for some reason
ActiveWindow.Refresh
Refresh

pgSize = newDoc.PageSizes(2).Name	'Letter page size

pageHeight = newDoc.PageSizes(2).Height
pageWidth = newDoc.PageSizes(2).Width
newDoc.Pages(0).SetSize pageWidth, pageHeight

'The following 2 lines place the page origin at the bottom left hand corner
newDoc.DrawingOriginX = -newDoc.ActivePage.SizeWidth / 2
newDoc.DrawingOriginY = -newDoc.ActivePage.SizeHeight / 2
'Exit Sub

'Call DefineCursorType
Load frmDataEntry
frmDataEntry.Show

newDoc.RestoreSettings
newDoc.EditAcrossLayers = False
newDoc.ReferencePoint = cdrCenter
EventsEnabled = True
Optimization = False
ActiveWindow.Refresh
    
'////--Error Trap Begin--////--////--Error Trap Begin--////--////--Error Trap Begin--////--////
Exit_createDoc:
Exit Sub

BailOut:
    
    Dim MyError, msg
    ' First, strip off the constant added by the object to indicate one
    ' of its own errors.
    MyError = Err.Number - vbObjectError
    ' If you subtract the vbObjectError constant, and the number is still
    ' in the range 0-65,535, it is an object-defined error code.
    If MyError > 0 And MyError < 65535 Then
        msg = "The object you accessed assigned this number to the error: " _
                 & MyError & ". The originator of the error was: " _
                & Err.Source & ". Press F1 to see originator's Help topic."
    ' Otherwise it is a Visual Basic error number.
    Else
        msg = "This error (# " & Err.Number & ") is a Visual Basic error" & _
                " number. Press Help button or F1 for the Visual Basic Help" _
                & " topic for this error."
    End If
        MsgBox msg, , "Object Error", Err.HelpFile, Err.HelpContext
    '    MsgBox "Err.Number = " & Err.Number & vbCrLf & _
    '         "Err.Description = " & Err.Description
    End
'////--Error Trap End--////--////--////--Error Trap End--////--////--////--Error Trap End--////--////

End Sub

Last edited by diwin; 25-06-2007 at 18:49.
Reply With Quote
  #4  
Old 26-06-2007, 05:36
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

I think you can ensure a correct zoom level by adding the code:
Code:
ActiveWindow.ActiveView.ToFitPage
Reply With Quote
  #5  
Old 26-06-2007, 12:02
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

No, your problem is that you are setting the page size after changing the units of measurements.

Document.PageSizes method is deprecated and should not be used. Instead, you should be using Application.PageSizes. However the page size returned by this will be in units specified by the Application.Units and not Document.Units. As a result, you'll get a Letter page size of 8.5 x 11 because Application.Unit is set to cdrInch. However when you call Page.SetSize they are interpreted as kilometers.

Just set the page size before you change the document units to kilometers.
Reply With Quote
  #6  
Old 26-06-2007, 18:43
diwin
Guest
 
Posts: n/a
Default

Thanks Alex.
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
Simple Bar code generator Webster Code Critique 2 06-09-2010 01:41
CDR12: TTF Font exporting - specify character code zlatev CorelDRAW/Corel DESIGNER VBA 0 03-12-2005 05:54
Text ENCODE Craig Tucker CorelDRAW/Corel DESIGNER VBA 10 26-01-2005 13:59
How to use events from CorelDRAW.Document in my code? me CorelDRAW/Corel DESIGNER VBA 2 30-10-2004 02:49
Generic code to process all shapes in a document glennwilton CorelDRAW/Corel DESIGNER VBA 0 05-09-2003 03:13


All times are GMT -5. The time now is 08:51.


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