OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   Macros/Add-ons (http://forum.oberonplace.com/forumdisplay.php?f=21)
-   -   How to use foreach (in C#) to iterate through Documents collection? (http://forum.oberonplace.com/showthread.php?t=24773)

FaneDuru 27-11-2016 10:09

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!

FaneDuru 27-11-2016 10:54

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);
                }
    }
}



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

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