<?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: MDI Form in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335640#M98992</link>
    <description>From the Visual Basic Help files of VB Design&lt;BR /&gt;
http://vbdesign.hypermart.net/cadpages/&lt;BR /&gt;
&lt;BR /&gt;
Hi all,&lt;BR /&gt;
&lt;BR /&gt;
I would like to expand on that if I may. This is a lttle demo I cooked up&lt;BR /&gt;
for you based on the thread so far.&lt;BR /&gt;
&lt;BR /&gt;
If you open a new project add a user form with a command button (keep the&lt;BR /&gt;
default names, and the location of the button and size of the form do not&lt;BR /&gt;
matter, this code will set them for you) then paste this into the code&lt;BR /&gt;
module of the form, you will get a demo of what Mark is saying. What will&lt;BR /&gt;
this demo do? It adds a option button to the form for every drawing open in&lt;BR /&gt;
AutoCAD (so you must be set for MDI) then you can select one of the option&lt;BR /&gt;
buttons (the drawing name is added to its caption) and click the button. the&lt;BR /&gt;
selected drawing is now active. It should not take much work to translate&lt;BR /&gt;
this into your application, but if you need help, by all means let me know.&lt;BR /&gt;
&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Private Sub CommandButton1_Click()&lt;BR /&gt;
Dim objCtl As Control&lt;BR /&gt;
Dim strName As String&lt;BR /&gt;
For Each objCtl In UserForm1.Controls&lt;BR /&gt;
If TypeOf objCtl Is OptionButton Then&lt;BR /&gt;
  If objCtl.Value = True Then&lt;BR /&gt;
    strName = objCtl.Caption&lt;BR /&gt;
    ThisDrawing.Application.Documents.Item(strName).Activate&lt;BR /&gt;
    objCtl.Caption = "Active Document"&lt;BR /&gt;
  End If&lt;BR /&gt;
End If&lt;BR /&gt;
Next&lt;BR /&gt;
ThisDrawing.Application.Update&lt;BR /&gt;
End Sub&lt;BR /&gt;
Private Sub UserForm_Initialize()&lt;BR /&gt;
Dim objDrawing As AcadDocument&lt;BR /&gt;
Dim ctlCheckBox As OptionButton&lt;BR /&gt;
Dim intCnt As Integer&lt;BR /&gt;
CommandButton1.Left = 2&lt;BR /&gt;
CommandButton1.top = 2&lt;BR /&gt;
CommandButton1.Caption = "Make Drawing Active"&lt;BR /&gt;
CommandButton1.Width = 108&lt;BR /&gt;
CommandButton1.Height = 20&lt;BR /&gt;
Me.Width = 120&lt;BR /&gt;
Me.Height = 50&lt;BR /&gt;
intCnt = 1&lt;BR /&gt;
For Each objDrawing In ThisDrawing.Application.Documents&lt;BR /&gt;
  UserForm1.Controls.Move 0, 20&lt;BR /&gt;
  intCnt = intCnt + 1&lt;BR /&gt;
  Set ctlCheckBox = UserForm1.Controls.Add("Forms.OptionButton.1", "Option "&lt;BR /&gt;
&amp;amp; intCnt, True)&lt;BR /&gt;
  ctlCheckBox.Caption = objDrawing.Name&lt;BR /&gt;
  ctlCheckBox.AutoSize = True&lt;BR /&gt;
  Me.Height = Me.Height + 23&lt;BR /&gt;
Next&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Randall Rath&lt;BR /&gt;
VB Design</description>
    <pubDate>Thu, 14 Oct 1999 17:40:45 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>1999-10-14T17:40:45Z</dc:date>
    <item>
      <title>MDI Form</title>
      <link>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335637#M98989</link>
      <description>hi,everyone&lt;BR /&gt;
we know A2K is MDI, it can open several documents at same time, but VB app&lt;BR /&gt;
using automation only can available the active document. the problem is how&lt;BR /&gt;
to activate other document and do some thing while the app is running?&lt;BR /&gt;
&lt;BR /&gt;
any ideals?&lt;BR /&gt;
&lt;BR /&gt;
thanks in advance&lt;BR /&gt;
Michael</description>
      <pubDate>Tue, 12 Oct 1999 15:07:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335637#M98989</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-10-12T15:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: MDI Form</title>
      <link>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335638#M98990</link>
      <description>The AcadDocuments collection of the AcadApplication object gives access to all&lt;BR /&gt;
open drawings.&lt;BR /&gt;
&lt;BR /&gt;
Mark Holder&lt;BR /&gt;
&lt;BR /&gt;
Michael Chen wrote:&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; hi,everyone&lt;BR /&gt;
&amp;gt; we know A2K is MDI, it can open several documents at same time, but VB app&lt;BR /&gt;
&amp;gt; using automation only can available the active document. the problem is how&lt;BR /&gt;
&amp;gt; to activate other document and do some thing while the app is running?&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; any ideals?&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; thanks in advance&lt;BR /&gt;
&amp;gt; Michael</description>
      <pubDate>Wed, 13 Oct 1999 12:38:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335638#M98990</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-10-13T12:38:53Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335639#M98991</link>
      <description>mark, thanks for your response. maybe i didn't make it clear.&lt;BR /&gt;
 i don't want to get the document or a object's( a line ...) application&lt;BR /&gt;
name, i want to do this : after doing something in current active document&lt;BR /&gt;
then  turn to activate another document and do some thing while the app is&lt;BR /&gt;
running?</description>
      <pubDate>Thu, 14 Oct 1999 14:21:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335639#M98991</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-10-14T14:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: MDI Form</title>
      <link>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335640#M98992</link>
      <description>From the Visual Basic Help files of VB Design&lt;BR /&gt;
http://vbdesign.hypermart.net/cadpages/&lt;BR /&gt;
&lt;BR /&gt;
Hi all,&lt;BR /&gt;
&lt;BR /&gt;
I would like to expand on that if I may. This is a lttle demo I cooked up&lt;BR /&gt;
for you based on the thread so far.&lt;BR /&gt;
&lt;BR /&gt;
If you open a new project add a user form with a command button (keep the&lt;BR /&gt;
default names, and the location of the button and size of the form do not&lt;BR /&gt;
matter, this code will set them for you) then paste this into the code&lt;BR /&gt;
module of the form, you will get a demo of what Mark is saying. What will&lt;BR /&gt;
this demo do? It adds a option button to the form for every drawing open in&lt;BR /&gt;
AutoCAD (so you must be set for MDI) then you can select one of the option&lt;BR /&gt;
buttons (the drawing name is added to its caption) and click the button. the&lt;BR /&gt;
selected drawing is now active. It should not take much work to translate&lt;BR /&gt;
this into your application, but if you need help, by all means let me know.&lt;BR /&gt;
&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Private Sub CommandButton1_Click()&lt;BR /&gt;
Dim objCtl As Control&lt;BR /&gt;
Dim strName As String&lt;BR /&gt;
For Each objCtl In UserForm1.Controls&lt;BR /&gt;
If TypeOf objCtl Is OptionButton Then&lt;BR /&gt;
  If objCtl.Value = True Then&lt;BR /&gt;
    strName = objCtl.Caption&lt;BR /&gt;
    ThisDrawing.Application.Documents.Item(strName).Activate&lt;BR /&gt;
    objCtl.Caption = "Active Document"&lt;BR /&gt;
  End If&lt;BR /&gt;
End If&lt;BR /&gt;
Next&lt;BR /&gt;
ThisDrawing.Application.Update&lt;BR /&gt;
End Sub&lt;BR /&gt;
Private Sub UserForm_Initialize()&lt;BR /&gt;
Dim objDrawing As AcadDocument&lt;BR /&gt;
Dim ctlCheckBox As OptionButton&lt;BR /&gt;
Dim intCnt As Integer&lt;BR /&gt;
CommandButton1.Left = 2&lt;BR /&gt;
CommandButton1.top = 2&lt;BR /&gt;
CommandButton1.Caption = "Make Drawing Active"&lt;BR /&gt;
CommandButton1.Width = 108&lt;BR /&gt;
CommandButton1.Height = 20&lt;BR /&gt;
Me.Width = 120&lt;BR /&gt;
Me.Height = 50&lt;BR /&gt;
intCnt = 1&lt;BR /&gt;
For Each objDrawing In ThisDrawing.Application.Documents&lt;BR /&gt;
  UserForm1.Controls.Move 0, 20&lt;BR /&gt;
  intCnt = intCnt + 1&lt;BR /&gt;
  Set ctlCheckBox = UserForm1.Controls.Add("Forms.OptionButton.1", "Option "&lt;BR /&gt;
&amp;amp; intCnt, True)&lt;BR /&gt;
  ctlCheckBox.Caption = objDrawing.Name&lt;BR /&gt;
  ctlCheckBox.AutoSize = True&lt;BR /&gt;
  Me.Height = Me.Height + 23&lt;BR /&gt;
Next&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Randall Rath&lt;BR /&gt;
VB Design</description>
      <pubDate>Thu, 14 Oct 1999 17:40:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335640#M98992</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-10-14T17:40:45Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335641#M98993</link>
      <description>Michael,&lt;BR /&gt;
&lt;BR /&gt;
I think I understood your question. Here is som code to show what I mean:&lt;BR /&gt;
&lt;BR /&gt;
In the ACAD session, there are 2 open drawings, "A", and "B". Drawing "A" is&lt;BR /&gt;
active.&lt;BR /&gt;
&lt;BR /&gt;
    Dim dwgB as AcadDocument&lt;BR /&gt;
&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    Set dwgB = myAcad.Documents("B")&lt;BR /&gt;
    If Err = 0 then&lt;BR /&gt;
        dwgB.Activate&lt;BR /&gt;
        ' do stuff with dwgB here ...&lt;BR /&gt;
    endif&lt;BR /&gt;
&lt;BR /&gt;
Michael Chen wrote:&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; mark, thanks for your response. maybe i didn't make it clear.&lt;BR /&gt;
&amp;gt;  i don't want to get the document or a object's( a line ...) application&lt;BR /&gt;
&amp;gt; name, i want to do this : after doing something in current active document&lt;BR /&gt;
&amp;gt; then  turn to activate another document and do some thing while the app is&lt;BR /&gt;
&amp;gt; running?</description>
      <pubDate>Thu, 14 Oct 1999 17:41:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335641#M98993</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-10-14T17:41:34Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335642#M98994</link>
      <description>thank Randall,&lt;BR /&gt;
your code is very good,and your "a code a day" is also very good.&lt;BR /&gt;
&lt;BR /&gt;
BTW, i want to batch plot many drawings which pen width connected with its&lt;BR /&gt;
color( i make a ctb file), i can use "plottofile filename,pc3file" method to&lt;BR /&gt;
load pc3 file, but i don't know how to load ctb file, can you give me some&lt;BR /&gt;
sample code. is it only choice to making pen width connected with color?&lt;BR /&gt;
&lt;BR /&gt;
good lucky!&lt;BR /&gt;
Michael&lt;BR /&gt;
&lt;BR /&gt;
Randall Rath &lt;RWRATH73&gt; wrote in message&lt;BR /&gt;
news:7u559b$2a09@adesknews2.autodesk.com...&lt;BR /&gt;
&amp;gt; From the Visual Basic Help files of VB Design&lt;BR /&gt;
&amp;gt; http://vbdesign.hypermart.net/cadpages/&lt;BR /&gt;
&amp;gt;&lt;/RWRATH73&gt;</description>
      <pubDate>Fri, 15 Oct 1999 15:23:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/mdi-form/m-p/335642#M98994</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-10-15T15:23:44Z</dc:date>
    </item>
  </channel>
</rss>

