OberonPlace.com Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old 26-09-2005, 12:10
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Well, control arrays are not supported by VBA and there is nothing Corel can do about it. It's the VBA's limitation and not the host application's. And I really doubt that Microsoft would do anything about it either because in VB.NET control arrays are not supported either...
Reply With Quote
  #12  
Old 02-10-2005, 10:12
petig
Guest
 
Posts: n/a
Default Constrain angle?

Maybe set or, at least, query the Options/Edit/Constrain angle from VBA? Which is the similar doc or app (workspace?) property?
Reply With Quote
  #13  
Old 26-10-2005, 12:33
petig
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Alex
[*]Document.ToUnits - converts any unit into the current document units (as specified by Document.Unit property)[*]Document.FromUnits - converts a value from the current document units into the given unit[/list]
Exuse me. Is it sure, ToUnits convert into ActiveDocument.Unit from the given unit? (Not in CDR 11, and I cann't try)
Reply With Quote
  #14  
Old 27-10-2005, 08:03
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Quote:
Originally Posted by petig
Exuse me. Is it sure, ToUnits convert into ActiveDocument.Unit from the given unit? (Not in CDR 11, and I cann't try)
Yes. Here is an example. By default, document units are inches. Here is what this command produces:

Code:
?ActiveDocument.ToUnits(10, cdrMillimeter)
 0.393700787401575

?ActiveDocument.FromUnits(10, cdrMillimeter)
 254
So, I converted 10 millimeters which produced 0.39". Then I converted 10 document units into millimeters, which converted 10" into 254 mm.
Reply With Quote
  #15  
Old 27-10-2005, 14:35
petig
Guest
 
Posts: n/a
Default

Well, thanks. That was ambiguous for me just because I confused with CorelScriptTools.ToCentimeter etc.
Reply With Quote
  #16  
Old 27-10-2005, 18:51
petig
Guest
 
Posts: n/a
Default What are the limits?

Uh, oh! Just a one more quick question! What are the limits of Draw even in vba for size and position (in tenthmicron), what a user may input on a form, such the sizing and positioning happens exactly by that values? Are they depends on the position of the rulers zeropoint (think so, but I'm not sure) or the rulers units, pagesize or any else? Shortly: has the desktop a limited size?
Reply With Quote
  #17  
Old 27-10-2005, 19:55
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Yes, there is a size limit. For all practical purposes, the desktop is 1800" x 1800" (45 x 45 meters) with the center in the center of the page.
Reply With Quote
  #18  
Old 28-10-2005, 19:37
petig
Guest
 
Posts: n/a
Default

Thanks for the quick answer!
Reply With Quote
  #19  
Old 29-10-2005, 07:49
petig
Guest
 
Posts: n/a
Default

For that reason there is an example forms code to nudge. It will warning and stop the action, if you try move any shape or its detail out of desktop with macro (like the user interface). For try, insert the codes to a User form what has two textboxes named InputXNudge and InputYNudge, and a commandbutton named OKButton. If the last function TooLargeValue inserted as public to another codemodul, then usable from any macros. Works only in CDR.12 (or higher) because the Document.FromUnit not in lower.

Code:
Private Sub InputXNudge_Exit(ByVal Cancel As MSForms.ReturnBoolean)
   Cancel = ValidateInput(InputXNudge, 0)
End Sub

Private Sub InputYNudge_Exit(ByVal Cancel As MSForms.ReturnBoolean)
   Cancel = ValidateInput(InputYNudge, 1)
End Sub

Private Sub OKButton_Click()

   Dim sr As ShapeRange, XNudge As Double, YNudge As Double

   If ActiveSelection Is Nothing Then
      MsgBox "First you must select some shape to nudge...", vbCritical
      Exit Sub
   End If

   Set sr = ActiveSelectionRange

   If Not IsNumeric(InputXNudge) Then InputXNudge = "0"
   XNudge = CDbl(InputXNudge)
   If Not IsNumeric(InputYNudge) Then InputYNudge = "0"
   YNudge = CDbl(InputYNudge)

   If XNudge < 0 Then
      If YNudge < 0 Then
         ActiveDocument.ReferencePoint = cdrBottomLeft
      Else
         ActiveDocument.ReferencePoint = cdrTopLeft
      End If
   Else
      If YNudge < 0 Then
         ActiveDocument.ReferencePoint = cdrBottomRight
      Else
         ActiveDocument.ReferencePoint = cdrTopRight
      End If
   End If

   If TooLargeValue(sr.PositionX + XNudge, 0) Then
      MsgBox "Horizontal nudge not allowed, because to out of desktop.", vbCritical, "Input error"
      Exit Sub
   ElseIf TooLargeValue(sr.PositionY + YNudge, 1) Then
      MsgBox "Vertical nudge not allowed, because to out of desktop.", vbCritical, "Input error"
      Exit Sub
   End If

   sr.Move XNudge, YNudge

End Sub

Private Function ValidateInput(cInput As TextBox, Direction As Integer) As Boolean

   If Trim(cInput) = "" Then
      cInput = 0
   ElseIf Not IsNumeric(cInput) Then
      MsgBox "Mistyped...", vbExclamation + vbMsgBoxSetForeground, "Input error"
      ValidateInput = True
   ElseIf TooLargeValue(cInput, Direction) Then
      MsgBox "Ssshh... to much!", vbCritical + vbMsgBoxSetForeground, "Input error"
      ValidateInput = True
   End If

End Function

Private Function TooLargeValue(cInput As Variant, Direction As Integer) As Boolean

   Dim LowLimit As Double, HighLimit As Double, cValue As Double

   If Direction = 0 Then 'Horizontal
      HighLimit = -1 * ActiveDocument.FromUnit(ActiveDocument.DrawingOriginX, cdrTenthMicron)
   Else                  'Vertical
      HighLimit = -1 * ActiveDocument.FromUnit(ActiveDocument.DrawingOriginY, cdrTenthMicron)
   End If

   LowLimit = HighLimit - 228600000#
   HighLimit = HighLimit + 228600000#
   cValue = ActiveDocument.FromUnit(CDbl(cInput), cdrTenthMicron)

   If LowLimit > cValue Or cValue > HighLimit Then TooLargeValue = True

End Function

Last edited by petig; 29-10-2005 at 07:58. Reason: A little mistype...
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
Where to begin with CorelDRAW and VBA shelbym CorelDRAW/Corel DESIGNER VBA 2 03-04-2007 10:15
delete vba project from cdr file hotairballoon CorelDRAW/Corel DESIGNER VBA 1 18-05-2005 10:08
CD 10, VBA not returning true outline width Webster CorelDRAW/Corel DESIGNER VBA 1 24-11-2004 18:09
VBA does not work with my CD 10 ! jobar CorelDRAW/Corel DESIGNER VBA 1 24-08-2003 13:38
Detect if VBA is installed (an answer and a question) reanan CorelDRAW/Corel DESIGNER VBA 3 04-12-2002 15:35


All times are GMT -5. The time now is 12:27.


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