<?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 Find Last Layout in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162865#M21519</link>
    <description>In order to create a new layout in my drawing, I'm trying to copy the last layout in my drawing...with the following code...&lt;BR /&gt;
&lt;BR /&gt;
objAcad.ActiveDocument.SendCommand("layout" &amp;amp; vbCr &amp;amp;  "c" &amp;amp; vbCr &amp;amp; _ objAcad.ActiveDocument.Layouts.Item(objAcad.ActiveDocument.Layouts.Count).Name &amp;amp; vbCr)&lt;BR /&gt;
&lt;BR /&gt;
Code which quickly returns the error message..."Value does not fall within the expected range."&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to somehow refer to the last layout in my drawing...&lt;BR /&gt;
&lt;BR /&gt;
Could anyone lend a hand please??&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
&lt;BR /&gt;
Pete</description>
    <pubDate>Wed, 23 Jan 2008 20:49:12 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-01-23T20:49:12Z</dc:date>
    <item>
      <title>Find Last Layout</title>
      <link>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162865#M21519</link>
      <description>In order to create a new layout in my drawing, I'm trying to copy the last layout in my drawing...with the following code...&lt;BR /&gt;
&lt;BR /&gt;
objAcad.ActiveDocument.SendCommand("layout" &amp;amp; vbCr &amp;amp;  "c" &amp;amp; vbCr &amp;amp; _ objAcad.ActiveDocument.Layouts.Item(objAcad.ActiveDocument.Layouts.Count).Name &amp;amp; vbCr)&lt;BR /&gt;
&lt;BR /&gt;
Code which quickly returns the error message..."Value does not fall within the expected range."&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to somehow refer to the last layout in my drawing...&lt;BR /&gt;
&lt;BR /&gt;
Could anyone lend a hand please??&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
&lt;BR /&gt;
Pete</description>
      <pubDate>Wed, 23 Jan 2008 20:49:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162865#M21519</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-23T20:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Find Last Layout</title>
      <link>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162866#M21520</link>
      <description>The Layouts.Count will give the the amount of Layouts but Item starts counting from 0 not 1 so try&lt;BR /&gt;
&lt;BR /&gt;
objAcad.ActiveDocument.Layouts.Item(objAcad.ActiveDocument.Layouts.Count-1).Name &amp;amp; vbCr)&lt;BR /&gt;
&lt;BR /&gt;
and see how that works for you</description>
      <pubDate>Wed, 23 Jan 2008 20:59:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162866#M21520</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-23T20:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Find Last Layout</title>
      <link>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162867#M21521</link>
      <description>Hi PellaCAD... you back at working solo?</description>
      <pubDate>Wed, 23 Jan 2008 21:20:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162867#M21521</guid>
      <dc:creator>mdhutchinson</dc:creator>
      <dc:date>2008-01-23T21:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Find Last Layout</title>
      <link>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162868#M21522</link>
      <description>Hi ya' hutch...&lt;BR /&gt;
&lt;BR /&gt;
Naw...I'm still gainfully employed...and lovin' it! (Still got my "second job" that I do in my "spare time"...and lovin' that too!)&lt;BR /&gt;
&lt;BR /&gt;
I'm puttin' the finishing touches (yeah right, like that'll ever happen...) on this latest VB.NET effort...getting better and better at this...&lt;BR /&gt;
&lt;BR /&gt;
(This VB user group seriously rocks!)&lt;BR /&gt;
&lt;BR /&gt;
Anyways, I'm climbin' back in under the hood...say "hey" via email sometime...later!&lt;BR /&gt;
&lt;BR /&gt;
Pedro&lt;BR /&gt;
&lt;BR /&gt;
(Thanks Rednut...your reply confirmed that I had forgotten to specify the name of the new layout tab!!! DOH!!!)</description>
      <pubDate>Wed, 23 Jan 2008 21:39:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162868#M21522</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-23T21:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Find Last Layout</title>
      <link>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162869#M21523</link>
      <description>I've tested this about 4 different ways...&lt;BR /&gt;
&lt;BR /&gt;
I still can not make the last layout tab the active tab.&lt;BR /&gt;
&lt;BR /&gt;
There is obviously something fundaMENTAL about how one is expected to work with layout tabs...&lt;BR /&gt;
&lt;BR /&gt;
Does anyone have any clues??&lt;BR /&gt;
&lt;BR /&gt;
I want to add a new layout by copying the last layout in a drawing.</description>
      <pubDate>Wed, 23 Jan 2008 22:42:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162869#M21523</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-23T22:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: Find Last Layout</title>
      <link>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162870#M21524</link>
      <description>Hi Pete, how about doing it with code instead of SendCommand?&lt;BR /&gt;
&lt;BR /&gt;
Sub CreateLayoutFromLastLayout()&lt;BR /&gt;
Dim oLayouts As AcadLayouts&lt;BR /&gt;
Dim oLayout As AcadLayout&lt;BR /&gt;
Dim oLayout2Copy As AcadLayout&lt;BR /&gt;
Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
Set oLayouts = ThisDrawing.Layouts&lt;BR /&gt;
i = oLayouts.Count - 1&lt;BR /&gt;
'Find the last Layout as shown in the Layout bar&lt;BR /&gt;
For Each oLayout In oLayouts&lt;BR /&gt;
    If oLayout.TabOrder = i Then Set oLayout2Copy = oLayout&lt;BR /&gt;
Next&lt;BR /&gt;
&lt;BR /&gt;
'Create the Layout&lt;BR /&gt;
Dim oCopiedLayout As AcadLayout&lt;BR /&gt;
Set oCopiedLayout = oLayouts.Add("MyNewLayout")&lt;BR /&gt;
&lt;BR /&gt;
'Now copy all of the objects from the original to the new&lt;BR /&gt;
Dim oArray() As AcadEntity&lt;BR /&gt;
ReDim oArray(oLayout2Copy.Block.Count - 1)&lt;BR /&gt;
For i = 0 To oLayout2Copy.Block.Count - 1&lt;BR /&gt;
    Set oArray(i) = oLayout2Copy.Block(i)&lt;BR /&gt;
Next&lt;BR /&gt;
ThisDrawing.CopyObjects oArray, oCopiedLayout.Block&lt;BR /&gt;
&lt;BR /&gt;
'Finally, copy the PlotConfig Settings&lt;BR /&gt;
oCopiedLayout.CopyFrom oLayout2Copy&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
"PellaCAD" wrote in message news:5828516@discussion.autodesk.com...&lt;BR /&gt;
In order to create a new layout in my drawing, I'm trying to copy the last &lt;BR /&gt;
layout in my drawing...with the following code...&lt;BR /&gt;
&lt;BR /&gt;
objAcad.ActiveDocument.SendCommand("layout" &amp;amp; vbCr &amp;amp;  "c" &amp;amp; vbCr &amp;amp; _ &lt;BR /&gt;
objAcad.ActiveDocument.Layouts.Item(objAcad.ActiveDocument.Layouts.Count).Name &lt;BR /&gt;
&amp;amp; vbCr)&lt;BR /&gt;
&lt;BR /&gt;
Code which quickly returns the error message..."Value does not fall within &lt;BR /&gt;
the expected range."&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to somehow refer to the last layout in my drawing...&lt;BR /&gt;
&lt;BR /&gt;
Could anyone lend a hand please??&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
&lt;BR /&gt;
Pete</description>
      <pubDate>Wed, 23 Jan 2008 23:46:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/find-last-layout/m-p/2162870#M21524</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-23T23:46:05Z</dc:date>
    </item>
  </channel>
</rss>

