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 27-11-2016, 10:09
FaneDuru FaneDuru is offline
Member
 
Join Date: May 2012
Posts: 35
Question How to use foreach (in C#) to iterate through Documents collection?

How can enumerate each (open) document from Documents Collection using C#?
I try something like that, but the line containing 'corel.Documents' is red:
Code:
using corel = Corel.Interop.VGCore;
 namespace DockerTest
 {
     public partial class DockerUI : UserControl
    {
        private corel.Application corelApp;
        public DockerUI(corel.Application app)
        {
            this.corelApp = app;
            InitializeComponent();
        }
         
        private void Button_Click(object sender, RoutedEventArgs e)
        {
              foreach (corel.Document d in corel.Documents) //problem...
                {
                    MessageBox.Show(d.Name);
                }
    }
}
I use Mcrosoft Visual Studio 13 and it sais: 'Corel.Interop.VGCore.Documents' is a 'type', which is not valid in the given context.

How to make it 'understand' that corel.Documents is a collection...?

Thanks in advance!
Reply With Quote
  #2  
Old 27-11-2016, 10:54
FaneDuru FaneDuru is offline
Member
 
Join Date: May 2012
Posts: 35
Default

Solved...

Code:
using corel = Corel.Interop.VGCore;
 namespace DockerTest
 {
     public partial class DockerUI : UserControl
    {
        private corel.Application corelApp;
        public DockerUI(corel.Application app)
        {
            this.corelApp = app;
            InitializeComponent();
        }
         
        private void Button_Click(object sender, RoutedEventArgs e)
        {
              foreach (corel.Document d in corelApp.Documents) //No problem any more...
                {
                    MessageBox.Show(d.Name);
                }
    }
}

Last edited by FaneDuru; 27-11-2016 at 11:03.
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
X7 VBA and Controls Collection DebG Macros/Add-ons 0 23-05-2014 15:39
::ForEach:: macro wOxxOm CorelDRAW/Corel DESIGNER VBA 2 08-12-2010 14:12
Same Macro to all documents Manuel CorelDRAW/Corel DESIGNER VBA 5 10-05-2007 14:30
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 17:40.


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