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 18-06-2003, 09:59
andyb
Guest
 
Posts: n/a
Default Looping layers: Why doesn't this work?

Hi,

Here's a simple piece of code:
Code:
    With CorelDRAW.ActiveDocument.ActivePage
        For I = 1 To .Layers.count
            MsgBox .Layers.Item(I).Name
        Next I
    End With
But I get an error saying that "I" is wrong*. If I hard code I to 1, or 2... it works. This would work to:

Code:
Const I as Byte = 1
Why can't I use variables when I specify the item?
(I encounter the same problem when looping through any type of object.)

*Let's say we set I=-1, we would get the same msg.


Thanks
Andy
Reply With Quote
  #2  
Old 10-07-2003, 18:41
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default Re: Looping layers: Why doesn't this work?

Quote:
Originally Posted by andyb
Why can't I use variables when I specify the item?
You can, you just need to declare your variables as Long:

Dim i As Long
i=2
...Layers(i)...

This will work.

Or better yet, use VBA's For Each statement:

Code:
Dim lr as Layer
For Each lr in ActivePage.Layers
    MsgBox lr.Name
Next lr
Looks simpler, huh?
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
Send to layers click101 CorelDRAW/Corel DESIGNER VBA 4 14-09-2004 02:46
File Converter - turning off layers venturian CorelDRAW/Corel DESIGNER VBA 6 27-01-2004 08:08
Whether the VBA can work with Unicode . Dino CorelDRAW/Corel DESIGNER VBA 5 27-08-2003 16:13
opendocument doesn't work in a VB project s_federici CorelDRAW/Corel DESIGNER VBA 7 17-06-2003 09:43
looping until documents.count = 0 bbolte CorelDRAW/Corel DESIGNER VBA 18 18-02-2003 15:03


All times are GMT -5. The time now is 02:50.


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