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 23-05-2014, 15:39
DebG DebG is offline
Junior Member
 
Join Date: Oct 2007
Posts: 12
Default X7 VBA and Controls Collection

The following VBA statement has always worked in previous versions of CorelDRAW. In X7 it causes a type mismatch error.

For Each MyControl In Controls

Is there a different way of stepping through controls on a form in X7?

The following code is from the VBA Help File in X5. It works in X5 and X6 but causes Type mismatch in X7

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a CommandButton named CommandButton1 and several other controls.
Dim CtrlHeight As Single
Dim CtrlTop As Single
Dim CtrlGap As Single

Private Sub CommandButton1_Click()
Dim MyControl As Control
CtrlTop = 5

For Each MyControl In Controls
If MyControl.Name = "CommandButton1" Then
'Don't move or resize this control.
Else
'Move method using named arguments
MyControl.Move Top:=CtrlTop, _
Height:=CtrlHeight, Left:=5

'Move method using unnamed arguments (left,
'top, width, height)
'MyControl.Move 5, CtrlTop, ,CtrlHeight

'Calculate top coordinate for next control
CtrlTop = CtrlTop + CtrlHeight + CtrlGap
End If
Next

End Sub
Private Sub UserForm_Initialize()
CtrlHeight = 20
CtrlGap = 5

CommandButton1.Caption = "Click to move controls"
CommandButton1.AutoSize = True
CommandButton1.Left = 120
CommandButton1.Top = CtrlTop

End Sub
Reply With Quote
Reply

Tags
control, vba


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
CorelDRAW X6 and Custom .NET Controls shelbym CorelDRAW/Corel DESIGNER VBA 1 18-04-2013 23:36
Access Controls by Variable aakkaarr CorelDRAW/Corel DESIGNER VBA 1 12-10-2009 22:04
MultiPage Controls Keefster CorelDRAW/Corel DESIGNER VBA 2 20-04-2009 10:53
Font Collection Booker CorelDRAW/Corel DESIGNER VBA 1 18-05-2006 10:05
draw 11 export collection to psd xombie Code Critique 5 23-11-2005 11:02


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


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