![]() |
#1
|
|||
|
|||
![]()
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? |
#3
|
|||
|
|||
![]()
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. |
#4
|
||||
|
||||
![]()
I think you can ensure a correct zoom level by adding the code:
Code:
ActiveWindow.ActiveView.ToFitPage |
#5
|
||||
|
||||
![]()
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. |
#6
|
|||
|
|||
![]()
Thanks Alex.
|
![]() |
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 |
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 |