<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Opening Document in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027253#M77468</link>
    <description>Hi Mikko,&lt;BR /&gt;
 I don't know if you have tried to run your code, I will say you did.  If you don't get any "Invalid execution context" let me know which version of AutoCAD you are using and any particular settings in your project.  I am doing almost the same thing in my code and I get the error message.</description>
    <pubDate>Thu, 26 Jul 2007 18:46:01 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2007-07-26T18:46:01Z</dc:date>
    <item>
      <title>Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027235#M77450</link>
      <description>I thought opening a list drawings from a user form was just matter of calling DocumentManager.Open method, but I can't make it work.  Can someone please give a hand on how to do it properly.  TIA</description>
      <pubDate>Tue, 24 Jul 2007 20:50:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027235#M77450</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-24T20:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027236#M77451</link>
      <description>Here is how I do it.&lt;BR /&gt;
&lt;BR /&gt;
(defun MyOpen (FileName ReadOnly / )&lt;BR /&gt;
&lt;BR /&gt;
(vla-Open&lt;BR /&gt;
 (vla-get-Documents&lt;BR /&gt;
  (vlax-get-Acad-Object)&lt;BR /&gt;
 )&lt;BR /&gt;
 FileName&lt;BR /&gt;
 (if ReadOnly&lt;BR /&gt;
  :vlax-true&lt;BR /&gt;
  :vlax-false&lt;BR /&gt;
 )&lt;BR /&gt;
)&lt;BR /&gt;
)&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
&lt;BR /&gt;
Tim&lt;BR /&gt;
"A blind man lets nothing block his vision."&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5668021@discussion.autodesk.com...&lt;BR /&gt;
I thought opening a list drawings from a user form was just matter of &lt;BR /&gt;
calling DocumentManager.Open method, but I can't make it work.  Can someone &lt;BR /&gt;
please give a hand on how to do it properly.  TIA&lt;/HJOHN&gt;</description>
      <pubDate>Tue, 24 Jul 2007 20:58:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027236#M77451</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-24T20:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027237#M77452</link>
      <description>Oops.  Wrong forum, but is still the same.&lt;BR /&gt;
&lt;BR /&gt;
DocumentManager.Open(&amp;lt; DrawingPath &amp;gt;, &amp;lt; ReadOnly &amp;gt;);&lt;BR /&gt;
&lt;BR /&gt;
At least that is how I do it in my C# app, and it works.  But you could also &lt;BR /&gt;
leave out the readonly options.&lt;BR /&gt;
&lt;BR /&gt;
DocumentManager.Open(&amp;lt; DrawingPath &amp;gt;);&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
&lt;BR /&gt;
Tim&lt;BR /&gt;
"A blind man lets nothing block his vision."&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;T.WILLEY&gt; wrote in message news:5668029@discussion.autodesk.com...&lt;BR /&gt;
Here is how I do it.&lt;BR /&gt;
&lt;BR /&gt;
(defun MyOpen (FileName ReadOnly / )&lt;BR /&gt;
&lt;BR /&gt;
(vla-Open&lt;BR /&gt;
 (vla-get-Documents&lt;BR /&gt;
  (vlax-get-Acad-Object)&lt;BR /&gt;
 )&lt;BR /&gt;
 FileName&lt;BR /&gt;
 (if ReadOnly&lt;BR /&gt;
  :vlax-true&lt;BR /&gt;
  :vlax-false&lt;BR /&gt;
 )&lt;BR /&gt;
)&lt;BR /&gt;
)&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
&lt;BR /&gt;
Tim&lt;BR /&gt;
"A blind man lets nothing block his vision."&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5668021@discussion.autodesk.com...&lt;BR /&gt;
I thought opening a list drawings from a user form was just matter of&lt;BR /&gt;
calling DocumentManager.Open method, but I can't make it work.  Can someone&lt;BR /&gt;
please give a hand on how to do it properly.  TIA&lt;/HJOHN&gt;&lt;/T.WILLEY&gt;</description>
      <pubDate>Tue, 24 Jul 2007 21:02:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027237#M77452</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-24T21:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027238#M77453</link>
      <description>Thank you Willey for replying but I still stuck on this issue.  Here is the line of code I am having trouble with: &lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(FilePath, False) FilePath is a valid IO file path, but I am getting this error msg "Invalid execution context" , I think it has something to do with the ApplicationExecutionContext, but I am not clear on how this works.  I trying to open the drawings from a user form opened by the Application.ShowModalDialog method.  Any help will be greatly appreciated.</description>
      <pubDate>Wed, 25 Jul 2007 12:46:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027238#M77453</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-25T12:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027239#M77454</link>
      <description>That explains it: unlike the VB modal user form, when a modal form is open &lt;BR /&gt;
in .NET API, you cannot use DocumentCollection object to open a drawing.&lt;BR /&gt;
&lt;BR /&gt;
Workaround would be either open the drawing prior to the modal dialog's &lt;BR /&gt;
openning, or open the dialog as modeless.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5668604@discussion.autodesk.com...&lt;BR /&gt;
Thank you Willey for replying but I still stuck on this issue.  Here is the &lt;BR /&gt;
line of code I am having trouble with:&lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(FilePath, &lt;BR /&gt;
False) FilePath is a valid IO file path, but I am getting this error msg &lt;BR /&gt;
"Invalid execution context" , I think it has something to do with the &lt;BR /&gt;
ApplicationExecutionContext, but I am not clear on how this works.  I trying &lt;BR /&gt;
to open the drawings from a user form opened by the &lt;BR /&gt;
Application.ShowModalDialog method.  Any help will be greatly appreciated.&lt;/HJOHN&gt;</description>
      <pubDate>Wed, 25 Jul 2007 14:18:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027239#M77454</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-25T14:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027240#M77455</link>
      <description>If your modal dialog is started from a command handler,&lt;BR /&gt;
register the command with CommandFlags.Session, and &lt;BR /&gt;
set your Form's Visible property to false before you call &lt;BR /&gt;
Open(), and back to true after Open() returns.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5668604@discussion.autodesk.com...&lt;BR /&gt;
Thank you Willey for replying but I still stuck on this issue.  Here is the line of code I am having trouble with: &lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(FilePath, False) FilePath is a valid IO file path, but I am getting this error msg "Invalid execution context" , I think it has something to do with the ApplicationExecutionContext, but I am not clear on how this works.  I trying to open the drawings from a user form opened by the Application.ShowModalDialog method.  Any help will be greatly appreciated.&lt;/HJOHN&gt;</description>
      <pubDate>Wed, 25 Jul 2007 17:38:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027240#M77455</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-25T17:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027241#M77456</link>
      <description>Tony,&lt;BR /&gt;
&lt;BR /&gt;
Question one what you said.&lt;BR /&gt;
&lt;BR /&gt;
Can this method be used on any dialog box?  I have routines where I use &lt;BR /&gt;
dialog boxes, and the information is stored within them.  Once the okay &lt;BR /&gt;
button is pressed I close the dialog, and fill an array with the contents of &lt;BR /&gt;
the dialog I want to store.  Could I just turn the dialog invisible instead, &lt;BR /&gt;
use the contents, then close the dialog?  Is this a good way, or just a work &lt;BR /&gt;
around?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.&lt;BR /&gt;
&lt;BR /&gt;
Sorry for the highjack.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
&lt;BR /&gt;
Tim&lt;BR /&gt;
"A blind man lets nothing block his vision."&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"Tony Tanzillo" &lt;TONY.TANZILLO&gt; wrote in message &lt;BR /&gt;
news:5669200@discussion.autodesk.com...&lt;BR /&gt;
If your modal dialog is started from a command handler,&lt;BR /&gt;
register the command with CommandFlags.Session, and&lt;BR /&gt;
set your Form's Visible property to false before you call&lt;BR /&gt;
Open(), and back to true after Open() returns.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5668604@discussion.autodesk.com...&lt;BR /&gt;
Thank you Willey for replying but I still stuck on this issue.  Here is the &lt;BR /&gt;
line of code I am having trouble with:&lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(FilePath, &lt;BR /&gt;
False) FilePath is a valid IO file path, but I am getting this error msg &lt;BR /&gt;
"Invalid execution context" , I think it has something to do with the &lt;BR /&gt;
ApplicationExecutionContext, but I am not clear on how this works.  I trying &lt;BR /&gt;
to open the drawings from a user form opened by the &lt;BR /&gt;
Application.ShowModalDialog method.  Any help will be greatly appreciated.&lt;/HJOHN&gt;&lt;/TONY.TANZILLO&gt;</description>
      <pubDate>Wed, 25 Jul 2007 18:49:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027241#M77456</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-25T18:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027242#M77457</link>
      <description>Thank you Tony.  Here is how I have made the command declaration:&lt;BR /&gt;
&lt;BR /&gt;
&lt;COMMANDMETHOD&gt; _&lt;BR /&gt;
        Public Shared Sub UpdateBox()&lt;BR /&gt;
        Dim frm As System.Windows.Forms.Form&lt;BR /&gt;
&lt;BR /&gt;
        frm = New frmUpdateDwgs&lt;BR /&gt;
                                                                                                    Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frm)&lt;BR /&gt;
&lt;BR /&gt;
frm.Dispose()&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
I still getting the same "Invalid execution context" error message.  Could you explain what does hiding the form while opening the drawings do. Any suggestions?&lt;/COMMANDMETHOD&gt;</description>
      <pubDate>Wed, 25 Jul 2007 19:45:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027242#M77457</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-25T19:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027243#M77458</link>
      <description>Hi Tim.&lt;BR /&gt;
&lt;BR /&gt;
As long as your code is running in the application &lt;BR /&gt;
context (e.g., the IsApplicationContext property &lt;BR /&gt;
of the DocumentManager is true), you should have&lt;BR /&gt;
no problem.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;T.WILLEY&gt; wrote in message news:5669321@discussion.autodesk.com...&lt;BR /&gt;
Tony,&lt;BR /&gt;
&lt;BR /&gt;
Question one what you said.&lt;BR /&gt;
&lt;BR /&gt;
Can this method be used on any dialog box?  I have routines where I use &lt;BR /&gt;
dialog boxes, and the information is stored within them.  Once the okay &lt;BR /&gt;
button is pressed I close the dialog, and fill an array with the contents of &lt;BR /&gt;
the dialog I want to store.  Could I just turn the dialog invisible instead, &lt;BR /&gt;
use the contents, then close the dialog?  Is this a good way, or just a work &lt;BR /&gt;
around?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.&lt;BR /&gt;
&lt;BR /&gt;
Sorry for the highjack.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
&lt;BR /&gt;
Tim&lt;BR /&gt;
"A blind man lets nothing block his vision."&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"Tony Tanzillo" &lt;TONY.TANZILLO&gt; wrote in message &lt;BR /&gt;
news:5669200@discussion.autodesk.com...&lt;BR /&gt;
If your modal dialog is started from a command handler,&lt;BR /&gt;
register the command with CommandFlags.Session, and&lt;BR /&gt;
set your Form's Visible property to false before you call&lt;BR /&gt;
Open(), and back to true after Open() returns.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5668604@discussion.autodesk.com...&lt;BR /&gt;
Thank you Willey for replying but I still stuck on this issue.  Here is the &lt;BR /&gt;
line of code I am having trouble with:&lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(FilePath, &lt;BR /&gt;
False) FilePath is a valid IO file path, but I am getting this error msg &lt;BR /&gt;
"Invalid execution context" , I think it has something to do with the &lt;BR /&gt;
ApplicationExecutionContext, but I am not clear on how this works.  I trying &lt;BR /&gt;
to open the drawings from a user form opened by the &lt;BR /&gt;
Application.ShowModalDialog method.  Any help will be greatly appreciated.&lt;/HJOHN&gt;&lt;/TONY.TANZILLO&gt;&lt;/T.WILLEY&gt;</description>
      <pubDate>Wed, 25 Jul 2007 20:57:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027243#M77458</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-25T20:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027244#M77459</link>
      <description>If that's happening then rather than hiding &lt;BR /&gt;
the form, in your command method, call &lt;BR /&gt;
ShowModalDialog() inside of a loop, and each &lt;BR /&gt;
time it returns DialogResult.Ok, open the &lt;BR /&gt;
drawing files. When ShowModalDialog() returns &lt;BR /&gt;
something other than DialogResult.Ok, exit&lt;BR /&gt;
the loop.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5669392@discussion.autodesk.com...&lt;BR /&gt;
Thank you Tony.  Here is how I have made the command declaration:&lt;BR /&gt;
&lt;BR /&gt;
&lt;COMMANDMETHOD&gt; _&lt;BR /&gt;
        Public Shared Sub UpdateBox()&lt;BR /&gt;
        Dim frm As System.Windows.Forms.Form&lt;BR /&gt;
&lt;BR /&gt;
        frm = New frmUpdateDwgs&lt;BR /&gt;
                                                                                                    Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frm)&lt;BR /&gt;
&lt;BR /&gt;
frm.Dispose()&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
I still getting the same "Invalid execution context" error message.  Could you explain what does hiding the form while opening the drawings do. Any suggestions?&lt;/COMMANDMETHOD&gt;&lt;/HJOHN&gt;</description>
      <pubDate>Wed, 25 Jul 2007 20:57:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027244#M77459</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-25T20:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027245#M77460</link>
      <description>Thanks Tony.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
&lt;BR /&gt;
Tim&lt;BR /&gt;
"A blind man lets nothing block his vision."&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"Tony Tanzillo" &lt;TONY.TANZILLO&gt; wrote in message &lt;BR /&gt;
news:5669567@discussion.autodesk.com...&lt;BR /&gt;
Hi Tim.&lt;BR /&gt;
&lt;BR /&gt;
As long as your code is running in the application&lt;BR /&gt;
context (e.g., the IsApplicationContext property&lt;BR /&gt;
of the DocumentManager is true), you should have&lt;BR /&gt;
no problem.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;T.WILLEY&gt; wrote in message news:5669321@discussion.autodesk.com...&lt;BR /&gt;
Tony,&lt;BR /&gt;
&lt;BR /&gt;
Question one what you said.&lt;BR /&gt;
&lt;BR /&gt;
Can this method be used on any dialog box?  I have routines where I use&lt;BR /&gt;
dialog boxes, and the information is stored within them.  Once the okay&lt;BR /&gt;
button is pressed I close the dialog, and fill an array with the contents of&lt;BR /&gt;
the dialog I want to store.  Could I just turn the dialog invisible instead,&lt;BR /&gt;
use the contents, then close the dialog?  Is this a good way, or just a work&lt;BR /&gt;
around?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.&lt;BR /&gt;
&lt;BR /&gt;
Sorry for the highjack.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
&lt;BR /&gt;
Tim&lt;BR /&gt;
"A blind man lets nothing block his vision."&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"Tony Tanzillo" &lt;TONY.TANZILLO&gt; wrote in message&lt;BR /&gt;
news:5669200@discussion.autodesk.com...&lt;BR /&gt;
If your modal dialog is started from a command handler,&lt;BR /&gt;
register the command with CommandFlags.Session, and&lt;BR /&gt;
set your Form's Visible property to false before you call&lt;BR /&gt;
Open(), and back to true after Open() returns.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5668604@discussion.autodesk.com...&lt;BR /&gt;
Thank you Willey for replying but I still stuck on this issue.  Here is the&lt;BR /&gt;
line of code I am having trouble with:&lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(FilePath,&lt;BR /&gt;
False) FilePath is a valid IO file path, but I am getting this error msg&lt;BR /&gt;
"Invalid execution context" , I think it has something to do with the&lt;BR /&gt;
ApplicationExecutionContext, but I am not clear on how this works.  I trying&lt;BR /&gt;
to open the drawings from a user form opened by the&lt;BR /&gt;
Application.ShowModalDialog method.  Any help will be greatly appreciated.&lt;/HJOHN&gt;&lt;/TONY.TANZILLO&gt;&lt;/T.WILLEY&gt;&lt;/TONY.TANZILLO&gt;</description>
      <pubDate>Wed, 25 Jul 2007 21:03:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027245#M77460</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-25T21:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027246#M77461</link>
      <description>Tony, maybe I have not being able to explain the situation clearly.  The "Invalid execution context" error occurs, when I try to iterate thru the list of drawings opening them.  The form frmUpdateDwgs works fine.  Once it is displayed the user can select drawings files from the system drives.  The problem is, when I try to open each drawing (hiding the form here didn't do anything).  In VBA this procedure works fine, but in .NET the Application/Document context restrictions make it difficult to make this code work.  Unfortunately, I don't have much documentation and I haven't been able to find anything meaningful on the subject.  I am starting to think that perhaps this won’t work.  Your help is really appreciated.</description>
      <pubDate>Wed, 25 Jul 2007 21:29:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027246#M77461</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-25T21:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027247#M77462</link>
      <description>Did you take this advice of Tony's:&lt;BR /&gt;
&lt;BR /&gt;
register the command with CommandFlags.Session</description>
      <pubDate>Wed, 25 Jul 2007 22:50:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027247#M77462</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-25T22:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027248#M77463</link>
      <description>Simply add CommandFlags.Session does not work. I tested this code:&lt;BR /&gt;
&lt;BR /&gt;
In command defining class:&lt;BR /&gt;
&lt;BR /&gt;
[CommandMethod("MyOpen", CommandFlags.Session)]&lt;BR /&gt;
&lt;BR /&gt;
public static void OpenFile()&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
using (dlgCmdTest dlg = new dlgCmdTest())&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(dlg);&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
dlgCmdTest is a win form with a button on it. The Button_Click event handler &lt;BR /&gt;
looks like:&lt;BR /&gt;
&lt;BR /&gt;
private void button1_Click(object sender, EventArgs e)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
string file = "E:\\Work\\Acad\\DataCadTest\\2007\\070202\\070202PC01R0.dwg";&lt;BR /&gt;
&lt;BR /&gt;
this.Visible = false; //Or this.Hide(); The same effect&lt;BR /&gt;
&lt;BR /&gt;
try&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(file);&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
catch (Autodesk.AutoCAD.Runtime.Exception ex)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
MessageBox.Show("Error: " + ex.Message);    //I got error "eNoDocument".&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
this.Visible = true;&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
After start Acad, NETLOAD the dll, issue command "MYOPEN", the form shows. &lt;BR /&gt;
Clicking the button, the MessageBox pops up.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;NATHAN taylor=""&gt; wrote in message news:5669714@discussion.autodesk.com...&lt;BR /&gt;
Did you take this advice of Tony's:&lt;BR /&gt;
&lt;BR /&gt;
register the command with CommandFlags.Session&lt;/NATHAN&gt;</description>
      <pubDate>Wed, 25 Jul 2007 23:46:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027248#M77463</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-25T23:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027249#M77464</link>
      <description>Did you see my last reply, and if so, did you try it?&lt;BR /&gt;
&lt;BR /&gt;
What I said was to place a loop in your command&lt;BR /&gt;
method function, and in the loop, show your dialog.&lt;BR /&gt;
After the call to ShowModalDialog() returns, then&lt;BR /&gt;
open the documents. &lt;BR /&gt;
&lt;BR /&gt;
Here's the C# code:&lt;BR /&gt;
&lt;BR /&gt;
public class MyForm : Form&lt;BR /&gt;
{&lt;BR /&gt;
    // set this to true to terminate looping:&lt;BR /&gt;
&lt;BR /&gt;
    public bool exitloop = false;&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
public class MyCommandClass&lt;BR /&gt;
{&lt;BR /&gt;
    [CommandMethod("MyCommand")]&lt;BR /&gt;
    public static void MyCommand()&lt;BR /&gt;
    {&lt;BR /&gt;
         MyForm form = new MyForm();&lt;BR /&gt;
         while( ! form.exitloop )&lt;BR /&gt;
         {&lt;BR /&gt;
             AcadApp.ShowModalDialog(form);&lt;BR /&gt;
             if( ! form.exitloop )&lt;BR /&gt;
                AcadApp.DocumentManager.Open(...);&lt;BR /&gt;
         }&lt;BR /&gt;
    }&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5669645@discussion.autodesk.com...&lt;BR /&gt;
Tony, maybe I have not being able to explain the situation clearly.  The "Invalid execution context" error occurs, when I try to iterate thru the list of drawings opening them.  The form frmUpdateDwgs works fine.  Once it is displayed the user can select drawings files from the system drives.  The problem is, when I try to open each drawing (hiding the form here didn't do anything).  In VBA this procedure works fine, but in .NET the Application/Document context restrictions make it difficult to make this code work.  Unfortunately, I don't have much documentation and I haven't been able to find anything meaningful on the subject.  I am starting to think that perhaps this won’t work.  Your help is really appreciated.&lt;/HJOHN&gt;</description>
      <pubDate>Thu, 26 Jul 2007 06:33:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027249#M77464</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-26T06:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027250#M77465</link>
      <description>Tony with all your respects, your suggestion doesn't work or I can't make it work.  The process is started from the command declaration and once the form is shown its code takes focus, only to pass it back to the command sub when the form is closed.  What I need is a way of making the DocumentManager.Open method work while the form is running. How or under which conditions does this method work?  Is it possible at all to have a form running and call this method?</description>
      <pubDate>Thu, 26 Jul 2007 13:49:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027250#M77465</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-26T13:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027251#M77466</link>
      <description>Here is the code I am working on or better yet trying to make it work:&lt;BR /&gt;
&lt;BR /&gt;
1- Command declaration&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.Windows&lt;BR /&gt;
Imports Autodesk.AutoCAD.ApplicationServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;
Imports System.Windows.Forms&lt;BR /&gt;
Public Class DrawingProcess&lt;BR /&gt;
    &lt;COMMANDMETHOD&gt; _&lt;BR /&gt;
    Public Shared Sub UpdateBox()&lt;BR /&gt;
&lt;BR /&gt;
        Dim frm As New frmUpdateDwg&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
        Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frm)&lt;BR /&gt;
&lt;BR /&gt;
        frm.Dispose()&lt;BR /&gt;
&lt;BR /&gt;
    End Sub&lt;BR /&gt;
   &lt;BR /&gt;
End Class&lt;BR /&gt;
&lt;BR /&gt;
2- Form class, Form + ListView + 3 Buttons&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.Windows&lt;BR /&gt;
Imports Autodesk.AutoCAD.ApplicationServices&lt;BR /&gt;
Imports System.Windows.Forms&lt;BR /&gt;
Public Class frmUpdateDwg&lt;BR /&gt;
    Public Function GetDrawings()&lt;BR /&gt;
&lt;BR /&gt;
        Dim opnFiles As Autodesk.AutoCAD.Windows.OpenFileDialog&lt;BR /&gt;
&lt;BR /&gt;
        opnFiles = New Autodesk.AutoCAD.Windows.OpenFileDialog("Select Files", "", "dwg", "Select Drawings", Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple)&lt;BR /&gt;
&lt;BR /&gt;
        opnFiles.ShowDialog()&lt;BR /&gt;
&lt;BR /&gt;
        Return opnFiles.GetFilenames&lt;BR /&gt;
&lt;BR /&gt;
    End Function&lt;BR /&gt;
&lt;BR /&gt;
    Public Sub LoadDrawings()&lt;BR /&gt;
        Dim Lst() As String&lt;BR /&gt;
        Dim FilePath As String&lt;BR /&gt;
        Dim ListItem As ListViewItem&lt;BR /&gt;
&lt;BR /&gt;
        Lst = Me.GetDrawings()&lt;BR /&gt;
&lt;BR /&gt;
        If Not Lst Is Nothing Then&lt;BR /&gt;
&lt;BR /&gt;
            If Lst.Length &amp;gt; 0 Then&lt;BR /&gt;
&lt;BR /&gt;
                Me.ListView1.BeginUpdate()&lt;BR /&gt;
&lt;BR /&gt;
                For Each FilePath In Lst&lt;BR /&gt;
&lt;BR /&gt;
                    If Me.ListView1.Items.ContainsKey(FilePath) = False Then&lt;BR /&gt;
&lt;BR /&gt;
                        ListItem = Me.ListView1.Items.Add(FilePath, System.IO.Path.GetFileName(FilePath), 0)&lt;BR /&gt;
                        ListItem.SubItems.Add(FilePath)&lt;BR /&gt;
&lt;BR /&gt;
                    End If&lt;BR /&gt;
&lt;BR /&gt;
                Next&lt;BR /&gt;
                Me.ListView1.EndUpdate()&lt;BR /&gt;
            End If&lt;BR /&gt;
        End If&lt;BR /&gt;
    End Sub&lt;BR /&gt;
&lt;BR /&gt;
    Private Sub ButtonAddDrawings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAddDrawings.Click&lt;BR /&gt;
        Call Me.LoadDrawings()&lt;BR /&gt;
    End Sub&lt;BR /&gt;
&lt;BR /&gt;
    Private Sub ButtonUpdateDrawings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonUpdateDrawings.Click&lt;BR /&gt;
        Dim ListItem As ListViewItem&lt;BR /&gt;
&lt;BR /&gt;
        If Me.ListView1.Items.Count &amp;gt; 0 Then&lt;BR /&gt;
            For Each ListItem In Me.ListView1.Items&lt;BR /&gt;
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(ListItem.SubItems(1).Text, False)&lt;BR /&gt;
            Next&lt;BR /&gt;
        End If&lt;BR /&gt;
    End Sub&lt;BR /&gt;
&lt;BR /&gt;
    Private Sub ButtonExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonExit.Click&lt;BR /&gt;
        Me.Close()&lt;BR /&gt;
    End Sub&lt;BR /&gt;
End Class&lt;BR /&gt;
&lt;BR /&gt;
Please someone take a look at this code and if you can make work, let me know how.  Thanks.&lt;/COMMANDMETHOD&gt;</description>
      <pubDate>Thu, 26 Jul 2007 17:33:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027251#M77466</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-26T17:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027252#M77467</link>
      <description>Maybe something like this?&lt;BR /&gt;
&lt;BR /&gt;
'=============================================&lt;BR /&gt;
'THE CLASS CODE:&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;
&lt;BR /&gt;
Public Class Class1&lt;BR /&gt;
&lt;BR /&gt;
&amp;lt;CommandMethod("HowTo", CommandFlags.Session)&amp;gt; Public Sub HowTo()&lt;BR /&gt;
Dim exam As New example&lt;BR /&gt;
exam.ShowDialog()&lt;BR /&gt;
exam.Dispose()&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
End Class&lt;BR /&gt;
&lt;BR /&gt;
'=============================================&lt;BR /&gt;
'THE WINDOWS FORM named example with one button:&lt;BR /&gt;
&lt;BR /&gt;
Public Class example&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;BR /&gt;
Dim fbd As New Windows.Forms.FolderBrowserDialog&lt;BR /&gt;
Dim ThisOne As String = ""&lt;BR /&gt;
If fbd.ShowDialog() = Windows.Forms.DialogResult.OK Then&lt;BR /&gt;
ThisOne = fbd.SelectedPath&lt;BR /&gt;
Else&lt;BR /&gt;
MsgBox("You must select a Folder")&lt;BR /&gt;
Exit Sub&lt;BR /&gt;
End If&lt;BR /&gt;
For Each foundFile As String In My.Computer.FileSystem.GetFiles(ThisOne, FileIO.SearchOption.SearchAllSubDirectories, "*.dwg")&lt;BR /&gt;
Dim docs As Autodesk.AutoCAD.ApplicationServices.DocumentCollection&lt;BR /&gt;
docs = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager&lt;BR /&gt;
Try&lt;BR /&gt;
docs.Open(foundFile, False)&lt;BR /&gt;
Catch Ex As Exception&lt;BR /&gt;
End Try&lt;BR /&gt;
Next&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
End Class</description>
      <pubDate>Thu, 26 Jul 2007 17:52:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027252#M77467</guid>
      <dc:creator>Mikko</dc:creator>
      <dc:date>2007-07-26T17:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027253#M77468</link>
      <description>Hi Mikko,&lt;BR /&gt;
 I don't know if you have tried to run your code, I will say you did.  If you don't get any "Invalid execution context" let me know which version of AutoCAD you are using and any particular settings in your project.  I am doing almost the same thing in my code and I get the error message.</description>
      <pubDate>Thu, 26 Jul 2007 18:46:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027253#M77468</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-07-26T18:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: Opening Document</title>
      <link>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027254#M77469</link>
      <description>2008 and yes this does work for me.  Nothing special, that is the whole of it.&lt;BR /&gt;
&lt;BR /&gt;
one more thing is, I'm not using:&lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frm)&lt;BR /&gt;
instead I use:&lt;BR /&gt;
exam.ShowDialog()

Message was edited by: Mikko</description>
      <pubDate>Thu, 26 Jul 2007 18:52:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/opening-document/m-p/2027254#M77469</guid>
      <dc:creator>Mikko</dc:creator>
      <dc:date>2007-07-26T18:52:19Z</dc:date>
    </item>
  </channel>
</rss>

