<?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: Runtime Error -2147467259 in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301580#M66659</link>
    <description>&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;
&lt;P&gt;You might want to look at XLOADCTL system variable. I have had success &lt;BR /&gt;
setting this variable on all my users machines. Sometimes without them knowing &lt;BR /&gt;
it (through code they use or by walking up to there computer and setting it). &lt;BR /&gt;
Once it is set (to 2) overlaying will be in place. Most users have never seen &lt;BR /&gt;
this variable and therefore are unlikely to change it.&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;Regards,&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;Rogue&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE dir="ltr"&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;"xiexieanke" &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:carmen.kuegler@web.de"&amp;gt;carmen.kuegler@web.de&lt;/A&gt;&amp;gt; wrote in &lt;BR /&gt;
  message &lt;A&gt;&lt;BR /&gt;
  href="news:f13a53a.-1@WebX.maYIadrTaRb"&amp;gt;news:f13a53a.-1@WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;Hi, &lt;BR /&gt;
  &lt;BR /&gt;I have attached several XREFs in a drawing. After plotting &lt;BR /&gt;I need to &lt;BR /&gt;
  detach the XREFs. So far I use the following code: &lt;BR /&gt;
  &lt;P&gt;Dim blockObjekt As AcadBlock &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;For Each blockObjekt In ThisDrawing.Blocks &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;if blockObjekt.IsXRef Then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If &lt;BR /&gt;
  blockObjekt.name &amp;lt;&amp;gt; "" Then &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Debug.Print &lt;BR /&gt;
  blockObjekt.name &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ThisDrawing.Blocks.Item(blockObjekt.name).Detach &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End &lt;BR /&gt;
  If &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Next blockObjekt &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;The first XREF is detached, after that I get a Runtime Error -2147467259 &lt;BR /&gt;
  and the routine ends. &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Does anybody know what happens? &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Carmen&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Thu, 23 Jan 2003 15:27:00 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2003-01-23T15:27:00Z</dc:date>
    <item>
      <title>Runtime Error -2147467259</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301562#M66641</link>
      <description>Hi,&lt;BR /&gt;
I have attached several XREFs in a drawing. After plotting&lt;BR /&gt;
I need to detach the XREFs. So far I use the following code:&lt;BR /&gt;
&lt;BR /&gt;
   Dim blockObjekt As AcadBlock&lt;BR /&gt;
&lt;BR /&gt;
   For Each blockObjekt In ThisDrawing.Blocks&lt;BR /&gt;
&lt;BR /&gt;
     if blockObjekt.IsXRef Then&lt;BR /&gt;
      If blockObjekt.name &amp;lt;&amp;gt; "" Then&lt;BR /&gt;
           Debug.Print blockObjekt.name&lt;BR /&gt;
           ThisDrawing.Blocks.Item(blockObjekt.name).Detach&lt;BR /&gt;
      End If&lt;BR /&gt;
    End If&lt;BR /&gt;
&lt;BR /&gt;
   Next blockObjekt&lt;BR /&gt;
&lt;BR /&gt;
The first XREF is detached, after that I get a Runtime Error -2147467259 and the routine ends.&lt;BR /&gt;
&lt;BR /&gt;
Does anybody know what happens?&lt;BR /&gt;
&lt;BR /&gt;
Carmen</description>
      <pubDate>Mon, 20 Jan 2003 09:02:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301562#M66641</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-20T09:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime Error -2147467259</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301563#M66642</link>
      <description>I got your code to run past the first block by replacing "Next blockObjekt"&lt;BR /&gt;
with just "Next".  Since you had deleted blockObjekt, when it tried to do&lt;BR /&gt;
the Next statement, the variable blockObjekt was no longer valid.&lt;BR /&gt;
&lt;BR /&gt;
But now your code still crashed after the LAST block.  My guess is that&lt;BR /&gt;
somehow it was trying to go "Next" PAST the last item in the collection.&lt;BR /&gt;
You could use an "On Error" handler to ignore this specific error number,&lt;BR /&gt;
and move on, but it's not a very pretty solution.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps,&lt;BR /&gt;
&lt;BR /&gt;
James</description>
      <pubDate>Mon, 20 Jan 2003 14:02:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301563#M66642</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-20T14:02:48Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301564#M66643</link>
      <description>As an aside, you can simplify your Detach statement to&lt;BR /&gt;
&lt;BR /&gt;
blockObject.Detach&lt;BR /&gt;
&lt;BR /&gt;
Sorry, though... this doesn't change the way the program runs.&lt;BR /&gt;
&lt;BR /&gt;
James</description>
      <pubDate>Mon, 20 Jan 2003 14:06:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301564#M66643</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-20T14:06:38Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301565#M66644</link>
      <description>OK... I made the change to use Error handling.  I'm a little embarassed to&lt;BR /&gt;
show this because I'm sure it abuses the true spirit of error handling...&lt;BR /&gt;
but it runs.&lt;BR /&gt;
&lt;BR /&gt;
James&lt;BR /&gt;
&lt;BR /&gt;
Dim blockObjekt As AcadBlock&lt;BR /&gt;
On Error Resume Next&lt;BR /&gt;
For Each blockObjekt In ThisDrawing.Blocks&lt;BR /&gt;
   if blockObjekt.IsXRef Then&lt;BR /&gt;
      If blockObjekt.name &amp;lt;&amp;gt; "" Then&lt;BR /&gt;
           Debug.Print blockObjekt.name&lt;BR /&gt;
           blockObjekt.Detach&lt;BR /&gt;
      End If&lt;BR /&gt;
    End If&lt;BR /&gt;
Next&lt;BR /&gt;
If Err.Number &amp;lt;&amp;gt; -2147467259 then&lt;BR /&gt;
   Dim ErrNum As Long&lt;BR /&gt;
   ErrNum = Err.Number  ' so other errors will still stop program...&lt;BR /&gt;
   On Error GoTo 0&lt;BR /&gt;
   Err.Raise (ErrNum)&lt;BR /&gt;
End If</description>
      <pubDate>Mon, 20 Jan 2003 14:24:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301565#M66644</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-20T14:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime Error -2147467259</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301566#M66645</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Well, now you have jinxed my code as well. I had exactly the same code as&lt;BR /&gt;
you, except for the blockObject name and when I tested it a couple of weeks&lt;BR /&gt;
ago it worked fine, now when I test it, I get the same error.&lt;BR /&gt;
&lt;BR /&gt;
...... further testing .......&lt;BR /&gt;
&lt;BR /&gt;
OK, it seems I only get the problem when I try and detach an xrefed drawing&lt;BR /&gt;
in that contains blocks. I would guess that the code is probably going&lt;BR /&gt;
through all block definitions, including those in a an xref. No doubt at&lt;BR /&gt;
some point the xref becomes detached and the block reference no longer&lt;BR /&gt;
exists and you have the problem and your code panics.&lt;BR /&gt;
&lt;BR /&gt;
I would be interested to hear if there is a better solution than trapping&lt;BR /&gt;
the error as suggested by James.&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
Sean Bartleet&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"xiexieanke" &lt;CARMEN.KUEGLER&gt; wrote in message&lt;BR /&gt;
news:f13a53a.-1@WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Hi,&lt;BR /&gt;
&amp;gt; I have attached several XREFs in a drawing. After plotting&lt;BR /&gt;
&amp;gt; I need to detach the XREFs. So far I use the following code:&lt;BR /&gt;
&amp;gt; Dim blockObjekt As AcadBlock&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; For Each blockObjekt In ThisDrawing.Blocks&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; if blockObjekt.IsXRef Then&lt;BR /&gt;
&amp;gt;       If blockObjekt.name &amp;lt;&amp;gt; "" Then&lt;BR /&gt;
&amp;gt;            Debug.Print blockObjekt.name&lt;BR /&gt;
&amp;gt;            ThisDrawing.Blocks.Item(blockObjekt.name).Detach&lt;BR /&gt;
&amp;gt;       End If&lt;BR /&gt;
&amp;gt;     End If&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Next blockObjekt&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; The first XREF is detached, after that I get a Runtime Error -2147467259&lt;BR /&gt;
and the routine ends.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Does anybody know what happens?&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Carmen&lt;BR /&gt;
&amp;gt;&lt;/CARMEN.KUEGLER&gt;</description>
      <pubDate>Mon, 20 Jan 2003 17:52:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301566#M66645</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-20T17:52:24Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301567#M66646</link>
      <description>I profess to know next-to-nothing about AutoCAD, however I just did a bit of investigation and on a new empty drawing I appear to have three Blocks predefined:  &lt;BR /&gt;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp; *Model_Space  &lt;BR /&gt;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp; *Paper_Space  &lt;BR /&gt;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp; *Paper_Space0  &lt;BR /&gt;&lt;BR /&gt;
I suspect you can't get rid of these.  If that is true, a couple of solutions spring to mind (other than the Resume Next).  You could do an If-test inside the loop to make sure the Block.Name is not one of these special names.  Or you could skip these special ones by changing the loop to:  &lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
For J = 3 to ThisDrawing.Blocks.Count - 1&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;Set blockObjekt = ThisDrawing.Blocks(J)&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;etc&lt;BR /&gt;
&lt;/PRE&gt;&lt;BR /&gt;
However I don't know enough to know whether the number of predefined blocks is constant, or the names of them are constant.  Any knowledgable ones care to comment?  &lt;BR /&gt;&lt;BR /&gt;
  &lt;BR /&gt;&lt;BR /&gt;
Regards  &lt;BR /&gt;&lt;BR /&gt;
  &lt;BR /&gt;&lt;BR /&gt;
Wayne Ivory  &lt;BR /&gt;</description>
      <pubDate>Mon, 20 Jan 2003 17:54:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301567#M66646</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-20T17:54:03Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301568#M66647</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
If your drawing has multiple xref's attached all with blocks defined in them&lt;BR /&gt;
your code leaves some Xref's attached. Hopefully there is a way out there to&lt;BR /&gt;
do this.&lt;BR /&gt;
&lt;BR /&gt;
Regards.&lt;BR /&gt;
&lt;BR /&gt;
Sean Bartleet&lt;BR /&gt;
&lt;BR /&gt;
"James Belshan" &lt;JLBELSHAN&gt; wrote in message&lt;BR /&gt;
news:D7011E213F5660D634781B93080BB2B8@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; OK... I made the change to use Error handling.  I'm a little embarassed to&lt;BR /&gt;
&amp;gt; show this because I'm sure it abuses the true spirit of error handling...&lt;BR /&gt;
&amp;gt; but it runs.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; James&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Dim blockObjekt As AcadBlock&lt;BR /&gt;
&amp;gt; On Error Resume Next&lt;BR /&gt;
&amp;gt; For Each blockObjekt In ThisDrawing.Blocks&lt;BR /&gt;
&amp;gt;    if blockObjekt.IsXRef Then&lt;BR /&gt;
&amp;gt;       If blockObjekt.name &amp;lt;&amp;gt; "" Then&lt;BR /&gt;
&amp;gt;            Debug.Print blockObjekt.name&lt;BR /&gt;
&amp;gt;            blockObjekt.Detach&lt;BR /&gt;
&amp;gt;       End If&lt;BR /&gt;
&amp;gt;     End If&lt;BR /&gt;
&amp;gt; Next&lt;BR /&gt;
&amp;gt; If Err.Number &amp;lt;&amp;gt; -2147467259 then&lt;BR /&gt;
&amp;gt;    Dim ErrNum As Long&lt;BR /&gt;
&amp;gt;    ErrNum = Err.Number  ' so other errors will still stop program...&lt;BR /&gt;
&amp;gt;    On Error GoTo 0&lt;BR /&gt;
&amp;gt;    Err.Raise (ErrNum)&lt;BR /&gt;
&amp;gt; End If&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;/JLBELSHAN&gt;</description>
      <pubDate>Mon, 20 Jan 2003 18:03:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301568#M66647</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-20T18:03:53Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301569#M66648</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
.............Further hacking..............&lt;BR /&gt;
&lt;BR /&gt;
I got the code below to work, It seems that blocks contained inside an xref&lt;BR /&gt;
are also listed in the blocks collection, when you remove the xref, the for&lt;BR /&gt;
eachblock in this drawing poops in its pants when suddenly a block that&lt;BR /&gt;
should be there is not there anymore (because the xref has been detached).&lt;BR /&gt;
It guess that it is not a good idea to do brain surgery on yourself.&lt;BR /&gt;
&lt;BR /&gt;
The next trick is to recognize nested xrefs and make sure that you don't try&lt;BR /&gt;
detach an xref that has already been removed because it was really a nested&lt;BR /&gt;
xref and the parent was removed. Does anyone have any ideas of how I can&lt;BR /&gt;
test for a nested xref and thereby avoid adding it to my list of names?&lt;BR /&gt;
&lt;BR /&gt;
Sub TTest()&lt;BR /&gt;
    Dim vList() As Variant&lt;BR /&gt;
    Dim I As Integer&lt;BR /&gt;
    Dim blkMyBlock As AcadBlock&lt;BR /&gt;
&lt;BR /&gt;
    I = -1&lt;BR /&gt;
    Debug.Print vbCrLf &amp;amp; "XXXXXXXXXXXXXXXXX"&lt;BR /&gt;
    For Each blkMyBlock In ThisDrawing.Blocks&lt;BR /&gt;
        Debug.Print blkMyBlock.Name, blkMyBlock.IsXRef, blkMyBlock.OwnerID&lt;BR /&gt;
        If blkMyBlock.IsXRef Then&lt;BR /&gt;
            If I &amp;lt; 0 Then I = 0&lt;BR /&gt;
            ReDim Preserve vList(0 To I)&lt;BR /&gt;
            vList(I) = blkMyBlock.Name&lt;BR /&gt;
            I = I + 1&lt;BR /&gt;
        End If&lt;BR /&gt;
    Next blkMyBlock&lt;BR /&gt;
    If I &amp;gt; 0 Then&lt;BR /&gt;
    '    For I = 0 To UBound(vList)&lt;BR /&gt;
    '        ThisDrawing.Blocks.Item(vList(I)).Detach&lt;BR /&gt;
    '    Next I&lt;BR /&gt;
    End If&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Please let me know if there is a better way and if you ahve any ide of how&lt;BR /&gt;
to test for a nested xref.&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
Sean Bartleet</description>
      <pubDate>Tue, 21 Jan 2003 08:36:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301569#M66648</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-21T08:36:32Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301570#M66649</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Me again.&lt;BR /&gt;
&lt;BR /&gt;
If you add a "On Error Resume Next" statement if the item no longer exists&lt;BR /&gt;
it will just be skipped and the code will carry on regardless.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Sub TTest()&lt;BR /&gt;
    Dim vList() As Variant&lt;BR /&gt;
    Dim I As Integer&lt;BR /&gt;
    Dim blkMyBlock As AcadBlock&lt;BR /&gt;
&lt;BR /&gt;
    I = -1&lt;BR /&gt;
    Debug.Print vbCrLf &amp;amp; "XXXXXXXXXXXXXXXXX"&lt;BR /&gt;
    For Each blkMyBlock In ThisDrawing.Blocks&lt;BR /&gt;
        Debug.Print blkMyBlock.Name, blkMyBlock.IsXRef, blkMyBlock.OwnerID&lt;BR /&gt;
        If blkMyBlock.IsXRef Then&lt;BR /&gt;
            If I &amp;lt; 0 Then I = 0&lt;BR /&gt;
            ReDim Preserve vList(0 To I)&lt;BR /&gt;
            vList(I) = blkMyBlock.Name&lt;BR /&gt;
            I = I + 1&lt;BR /&gt;
        End If&lt;BR /&gt;
    Next blkMyBlock&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    If I &amp;gt; 0 Then&lt;BR /&gt;
        For I = 0 To UBound(vList)&lt;BR /&gt;
            ThisDrawing.Blocks.Item(vList(I)).Detach&lt;BR /&gt;
        Next I&lt;BR /&gt;
    End If&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Ciao.&lt;BR /&gt;
&lt;BR /&gt;
Sean</description>
      <pubDate>Tue, 21 Jan 2003 08:44:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301570#M66649</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-21T08:44:20Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301571#M66650</link>
      <description>&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Hi Wayne,&amp;nbsp; At minimum any drawing will always &lt;BR /&gt;
have *Model_Space and *Paper_Space.&amp;nbsp; Each layout added to the drawing will &lt;BR /&gt;
add another *Paper_Space(0...n) entry to the block table.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;I don't presume to be "knowledgeable", &lt;BR /&gt;
but&amp;nbsp;I've never let that stop me from commenting &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;-- &lt;BR /&gt;Bobby &lt;BR /&gt;
C. Jones&lt;BR /&gt;&lt;A href="http://www.AcadX.com"&gt;www.AcadX.com&lt;/A&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;"wivory" &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:waynei@wespine.com"&amp;gt;waynei@wespine.com&lt;/A&gt;&amp;gt; wrote in message &lt;BR /&gt;
  &lt;A&gt;&lt;BR /&gt;
  href="news:f13a53a.4@WebX.maYIadrTaRb"&amp;gt;news:f13a53a.4@WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;I &lt;BR /&gt;
  profess to know next-to-nothing about AutoCAD, however I just did a bit of &lt;BR /&gt;
  investigation and on a new empty drawing I appear to have three Blocks &lt;BR /&gt;
  predefined: &lt;BR /&gt;&amp;nbsp;&amp;nbsp; *Model_Space &lt;BR /&gt;&amp;nbsp;&amp;nbsp; *Paper_Space &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp; *Paper_Space0 &lt;BR /&gt;I suspect you can't get rid of these. If &lt;BR /&gt;
  that is true, a couple of solutions spring to mind (other than the Resume &lt;BR /&gt;
  Next). You could do an If-test inside the loop to make sure the Block.Name is &lt;BR /&gt;
  not one of these special names. Or you could skip these special ones by &lt;BR /&gt;
  changing the loop to: &lt;BR /&gt;&lt;PRE&gt; &lt;BR /&gt;
For J = 3 to ThisDrawing.Blocks.Count - 1 &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;Set blockObjekt = ThisDrawing.Blocks(J) &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;etc &lt;BR /&gt;
&lt;/PRE&gt;However I don't know enough to know whether the number of predefined &lt;BR /&gt;
  blocks is constant, or the names of them are constant. Any knowledgable ones &lt;BR /&gt;
  care to comment? &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Regards &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Wayne Ivory &lt;BR /&gt;
  &lt;BR /&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 21 Jan 2003 12:07:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301571#M66650</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-21T12:07:49Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301572#M66651</link>
      <description>"wivory" &lt;WAYNEI&gt; wrote in message&lt;BR /&gt;
news:f13a53a.4@WebX.maYIadrTaRb...&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; However I don't know enough to know whether the number of&lt;BR /&gt;
&amp;gt; predefined blocks is constant, or the names of them are constant.&lt;BR /&gt;
&lt;BR /&gt;
There's a minimum of two layouts (one model and one paper) but the&lt;BR /&gt;
number of paper space layouts is open ended. To avoid processing layout&lt;BR /&gt;
blocks, use the IsLayout property:&lt;BR /&gt;
&lt;BR /&gt;
For Each blockDef In ThisDrawing.Blocks&lt;BR /&gt;
    If Not blockDef.IsLayout Then&lt;BR /&gt;
        ' do your thing&lt;BR /&gt;
    End If&lt;BR /&gt;
Next&lt;BR /&gt;
&lt;BR /&gt;
--&lt;BR /&gt;
Someone left the grass out in the yard all night.&lt;BR /&gt;
http://www.acadx.com&lt;/WAYNEI&gt;</description>
      <pubDate>Tue, 21 Jan 2003 12:10:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301572#M66651</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-21T12:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime Error -2147467259</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301573#M66652</link>
      <description>&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;STRONG&gt;The trick lies in the fact, that you assume &lt;BR /&gt;
that &lt;/STRONG&gt;&lt;FONT face="Times New Roman" size="3"&gt;blockObjekt &lt;FONT face="Arial"&gt;&lt;BR /&gt;
size=2&amp;gt;&lt;STRONG&gt;remains as is during the loop. It does &lt;BR /&gt;
not.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;STRONG&gt;The loop should be constructed with a &lt;BR /&gt;
do...while statement checking the &amp;lt;COUNT&amp;gt; property&amp;nbsp; of the collection &lt;BR /&gt;
you are stepping through.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;STRONG&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/DIV&gt;&lt;STRONG&gt;&lt;FONT&gt;&lt;BR /&gt;
face=Arial size=2&amp;gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;BR /&gt;-- &lt;BR /&gt;Greetings, m.vr.gr.&lt;BR /&gt;W.K.M. van Rij&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;Brix Engineering&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;Gorinchem, Netherlands&lt;/DIV&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE dir="ltr"&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;xiexieanke &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:carmen.kuegler@web.de"&amp;gt;carmen.kuegler@web.de&lt;/A&gt;&amp;gt; schreef in &lt;BR /&gt;
  berichtnieuws &lt;A&gt;&lt;BR /&gt;
  href="mailto:f13a53a.-1@WebX.maYIadrTaRb"&amp;gt;f13a53a.-1@WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;Hi, &lt;BR /&gt;
  &lt;BR /&gt;I have attached several XREFs in a drawing. After plotting &lt;BR /&gt;I need to &lt;BR /&gt;
  detach the XREFs. So far I use the following code: &lt;BR /&gt;
  &lt;P&gt;Dim blockObjekt As AcadBlock &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;For Each blockObjekt In ThisDrawing.Blocks &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;if blockObjekt.IsXRef Then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If &lt;BR /&gt;
  blockObjekt.name &amp;lt;&amp;gt; "" Then &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Debug.Print &lt;BR /&gt;
  blockObjekt.name &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ThisDrawing.Blocks.Item(blockObjekt.name).Detach &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End &lt;BR /&gt;
  If &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Next blockObjekt &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;The first XREF is detached, after that I get a Runtime Error -2147467259 &lt;BR /&gt;
  and the routine ends. &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Does anybody know what happens? &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Carmen&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 22 Jan 2003 00:29:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301573#M66652</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-22T00:29:32Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301574#M66653</link>
      <description>Aaaha,&lt;BR /&gt;
&lt;BR /&gt;
Thanks for that observation, I need to think outside my box.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.&lt;BR /&gt;
&lt;BR /&gt;
Sean Bartleet&lt;BR /&gt;
&lt;BR /&gt;
"w.k.m. van Rij" &lt;WKMVRIJ&gt; wrote in message&lt;BR /&gt;
news:D64B481761947B308ABCB1FAA654AAAE@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; The trick lies in the fact, that you assume that blockObjekt remains as is&lt;BR /&gt;
during the loop. It does not.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; The loop should be constructed with a do...while statement checking the&lt;BR /&gt;
&lt;COUNT&gt; property  of the collection you are stepping through.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; --&lt;BR /&gt;
&amp;gt; Greetings, m.vr.gr.&lt;BR /&gt;
&amp;gt; W.K.M. van Rij&lt;BR /&gt;
&amp;gt; Brix Engineering&lt;BR /&gt;
&amp;gt; Gorinchem, Netherlands&lt;/COUNT&gt;&lt;/WKMVRIJ&gt;</description>
      <pubDate>Wed, 22 Jan 2003 07:07:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301574#M66653</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-22T07:07:47Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301575#M66654</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Why does the following code give me a runtime error -2145386475 Duplicate&lt;BR /&gt;
key?&lt;BR /&gt;
This seems to occur when I have at least two xref's attached where one of&lt;BR /&gt;
them includes a nested xref. The nested xref does not necessarily have the&lt;BR /&gt;
same name as the other xref.&lt;BR /&gt;
&lt;BR /&gt;
Sub TTest()&lt;BR /&gt;
    Dim I As Integer&lt;BR /&gt;
    I = 0&lt;BR /&gt;
    While I &amp;lt; ThisDrawing.Blocks.Count&lt;BR /&gt;
    Debug.Print ThisDrawing.Blocks.Item(I).Name,&lt;BR /&gt;
ThisDrawing.Blocks.Item(I).IsXRef&lt;BR /&gt;
    Set blkMyBlock = ThisDrawing.Blocks.Item(I)&lt;BR /&gt;
        If ThisDrawing.Blocks.Item(I).IsXRef Then&lt;BR /&gt;
            ThisDrawing.Blocks.Item(I).Detach&lt;BR /&gt;
        End If&lt;BR /&gt;
        I = I + 1&lt;BR /&gt;
    Wend&lt;BR /&gt;
&lt;BR /&gt;
Does anyone know how to test for nested xrefs?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in anticipation.&lt;BR /&gt;
&lt;BR /&gt;
Sean Bartleet&lt;BR /&gt;
&lt;BR /&gt;
"w.k.m. van Rij" &lt;WKMVRIJ&gt; wrote in message&lt;BR /&gt;
news:D64B481761947B308ABCB1FAA654AAAE@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; The trick lies in the fact, that you assume that blockObjekt remains as is&lt;BR /&gt;
during the loop. It does not.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; The loop should be constructed with a do...while statement checking the&lt;BR /&gt;
&lt;COUNT&gt; property  of the collection you are stepping through.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; --&lt;BR /&gt;
&amp;gt; Greetings, m.vr.gr.&lt;BR /&gt;
&amp;gt; W.K.M. van Rij&lt;BR /&gt;
&amp;gt; Brix Engineering&lt;/COUNT&gt;&lt;/WKMVRIJ&gt;</description>
      <pubDate>Wed, 22 Jan 2003 13:00:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301575#M66654</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-22T13:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime Error -2147467259</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301576#M66655</link>
      <description>&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;The solution is to restart your FOR EACH loop after &lt;BR /&gt;
each detachment:&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;restart:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each objblk In &lt;BR /&gt;
xdwg.Blocks&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If objblk.IsXRef = &lt;BR /&gt;
True Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
objblk.Detach&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
GoTo restart&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End &lt;BR /&gt;
If&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next objblk&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE dir="ltr"&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;"xiexieanke" &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:carmen.kuegler@web.de"&amp;gt;carmen.kuegler@web.de&lt;/A&gt;&amp;gt; wrote in &lt;BR /&gt;
  message &lt;A&gt;&lt;BR /&gt;
  href="news:f13a53a.-1@WebX.maYIadrTaRb"&amp;gt;news:f13a53a.-1@WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;Hi, &lt;BR /&gt;
  &lt;BR /&gt;I have attached several XREFs in a drawing. After plotting &lt;BR /&gt;I need to &lt;BR /&gt;
  detach the XREFs. So far I use the following code: &lt;BR /&gt;
  &lt;P&gt;Dim blockObjekt As AcadBlock &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;For Each blockObjekt In ThisDrawing.Blocks &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;if blockObjekt.IsXRef Then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If &lt;BR /&gt;
  blockObjekt.name &amp;lt;&amp;gt; "" Then &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Debug.Print &lt;BR /&gt;
  blockObjekt.name &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ThisDrawing.Blocks.Item(blockObjekt.name).Detach &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End &lt;BR /&gt;
  If &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Next blockObjekt &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;The first XREF is detached, after that I get a Runtime Error -2147467259 &lt;BR /&gt;
  and the routine ends. &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Does anybody know what happens? &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Carmen&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 22 Jan 2003 13:29:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301576#M66655</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-22T13:29:31Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301577#M66656</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
That works but still gives an error -2145386475 Duplicate key when you try&lt;BR /&gt;
and detach a drawing that occurs both as a primary xref and as a nested&lt;BR /&gt;
xref, unless you happen to detach the drawing with the nested xref first.&lt;BR /&gt;
&lt;BR /&gt;
I am still looking for any information on how to detect a duplicate xref.&lt;BR /&gt;
(Without searching through all the block names and checking for duplicates)&lt;BR /&gt;
&lt;BR /&gt;
But thanks for the code tip.&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
Sean Bartleet&lt;BR /&gt;
&lt;BR /&gt;
"RogueDrafter" &lt;NOSPAM&gt; wrote in message&lt;BR /&gt;
news:69C5E94175D3CE081B30ECC8F3C2559F@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; The solution is to restart your FOR EACH loop after each detachment:&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; restart:&lt;BR /&gt;
&amp;gt;     For Each objblk In xdwg.Blocks&lt;BR /&gt;
&amp;gt;         If objblk.IsXRef = True Then&lt;BR /&gt;
&amp;gt;             objblk.Detach&lt;BR /&gt;
&amp;gt;             GoTo restart&lt;BR /&gt;
&amp;gt;         End If&lt;BR /&gt;
&amp;gt;     Next objblk&lt;BR /&gt;
&amp;gt;   "xiexieanke" &lt;CARMEN.KUEGLER&gt; wrote in message&lt;BR /&gt;
news:f13a53a.-1@WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt;   Hi,&lt;BR /&gt;
&amp;gt;   I have attached several XREFs in a drawing. After plotting&lt;BR /&gt;
&amp;gt;   I need to detach the XREFs. So far I use the following code:&lt;BR /&gt;
&amp;gt;   Dim blockObjekt As AcadBlock&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;   For Each blockObjekt In ThisDrawing.Blocks&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;   if blockObjekt.IsXRef Then&lt;BR /&gt;
&amp;gt;         If blockObjekt.name &amp;lt;&amp;gt; "" Then&lt;BR /&gt;
&amp;gt;              Debug.Print blockObjekt.name&lt;BR /&gt;
&amp;gt;              ThisDrawing.Blocks.Item(blockObjekt.name).Detach&lt;BR /&gt;
&amp;gt;         End If&lt;BR /&gt;
&amp;gt;       End If&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;   Next blockObjekt&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;   The first XREF is detached, after that I get a Runtime Error -2147467259&lt;BR /&gt;
and the routine ends.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;   Does anybody know what happens?&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;   Carmen&lt;BR /&gt;
&amp;gt;&lt;/CARMEN.KUEGLER&gt;&lt;/NOSPAM&gt;</description>
      <pubDate>Wed, 22 Jan 2003 17:47:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301577#M66656</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-22T17:47:50Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301578#M66657</link>
      <description>I'm wondering why you would bring in an XREF twice I guess.  Have you&lt;BR /&gt;
considered (or would it work for you) using the Overlay option when you&lt;BR /&gt;
bring in an XREF?&lt;BR /&gt;
&lt;BR /&gt;
"Sean Bartleet" &lt;SEANBXX&gt; wrote in message&lt;BR /&gt;
news:15A1E29E00DC4CEB2007EEECE2DD7C4D@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Hi,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; That works but still gives an error -2145386475 Duplicate key when you try&lt;BR /&gt;
&amp;gt; and detach a drawing that occurs both as a primary xref and as a nested&lt;BR /&gt;
&amp;gt; xref, unless you happen to detach the drawing with the nested xref first.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; I am still looking for any information on how to detect a duplicate xref.&lt;BR /&gt;
&amp;gt; (Without searching through all the block names and checking for&lt;BR /&gt;
duplicates)&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; But thanks for the code tip.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Regards&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Sean Bartleet&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; "RogueDrafter" &lt;NOSPAM&gt; wrote in message&lt;BR /&gt;
&amp;gt; news:69C5E94175D3CE081B30ECC8F3C2559F@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; &amp;gt; The solution is to restart your FOR EACH loop after each detachment:&lt;BR /&gt;
&amp;gt; &amp;gt;&lt;BR /&gt;
&amp;gt; &amp;gt; restart:&lt;BR /&gt;
&amp;gt; &amp;gt;     For Each objblk In xdwg.Blocks&lt;BR /&gt;
&amp;gt; &amp;gt;         If objblk.IsXRef = True Then&lt;BR /&gt;
&amp;gt; &amp;gt;             objblk.Detach&lt;BR /&gt;
&amp;gt; &amp;gt;             GoTo restart&lt;BR /&gt;
&amp;gt; &amp;gt;         End If&lt;BR /&gt;
&amp;gt; &amp;gt;     Next objblk&lt;BR /&gt;
&amp;gt; &amp;gt;   "xiexieanke" &lt;CARMEN.KUEGLER&gt; wrote in message&lt;BR /&gt;
&amp;gt; news:f13a53a.-1@WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; &amp;gt;   Hi,&lt;BR /&gt;
&amp;gt; &amp;gt;   I have attached several XREFs in a drawing. After plotting&lt;BR /&gt;
&amp;gt; &amp;gt;   I need to detach the XREFs. So far I use the following code:&lt;BR /&gt;
&amp;gt; &amp;gt;   Dim blockObjekt As AcadBlock&lt;BR /&gt;
&amp;gt; &amp;gt;&lt;BR /&gt;
&amp;gt; &amp;gt;   For Each blockObjekt In ThisDrawing.Blocks&lt;BR /&gt;
&amp;gt; &amp;gt;&lt;BR /&gt;
&amp;gt; &amp;gt;   if blockObjekt.IsXRef Then&lt;BR /&gt;
&amp;gt; &amp;gt;         If blockObjekt.name &amp;lt;&amp;gt; "" Then&lt;BR /&gt;
&amp;gt; &amp;gt;              Debug.Print blockObjekt.name&lt;BR /&gt;
&amp;gt; &amp;gt;              ThisDrawing.Blocks.Item(blockObjekt.name).Detach&lt;BR /&gt;
&amp;gt; &amp;gt;         End If&lt;BR /&gt;
&amp;gt; &amp;gt;       End If&lt;BR /&gt;
&amp;gt; &amp;gt;&lt;BR /&gt;
&amp;gt; &amp;gt;   Next blockObjekt&lt;BR /&gt;
&amp;gt; &amp;gt;&lt;BR /&gt;
&amp;gt; &amp;gt;   The first XREF is detached, after that I get a Runtime&lt;BR /&gt;
Error -2147467259&lt;BR /&gt;
&amp;gt; and the routine ends.&lt;BR /&gt;
&amp;gt; &amp;gt;&lt;BR /&gt;
&amp;gt; &amp;gt;   Does anybody know what happens?&lt;BR /&gt;
&amp;gt; &amp;gt;&lt;BR /&gt;
&amp;gt; &amp;gt;   Carmen&lt;BR /&gt;
&amp;gt; &amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;/CARMEN.KUEGLER&gt;&lt;/NOSPAM&gt;&lt;/SEANBXX&gt;</description>
      <pubDate>Thu, 23 Jan 2003 10:13:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301578#M66657</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-23T10:13:00Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301579#M66658</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I just want to make my code robust so that if works for all situations.&lt;BR /&gt;
&lt;BR /&gt;
Indeed the overlay is often the way to go. I have been particularly slack in&lt;BR /&gt;
using this feature. I frequently discover situations where this has&lt;BR /&gt;
occurred. I guess that I should be trapping this situation and reminding the&lt;BR /&gt;
user through some obnoxious message to use overlays in future.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the tip.&lt;BR /&gt;
&lt;BR /&gt;
Sean&lt;BR /&gt;
&lt;BR /&gt;
"RogueDrafter" &lt;NOSPAM&gt; wrote in message&lt;BR /&gt;
news:3D3BB792D85A77EB3B86AF681FCB48BB@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; I'm wondering why you would bring in an XREF twice I guess.  Have you&lt;BR /&gt;
&amp;gt; considered (or would it work for you) using the Overlay option when you&lt;BR /&gt;
&amp;gt; bring in an XREF?&lt;/NOSPAM&gt;</description>
      <pubDate>Thu, 23 Jan 2003 14:03:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301579#M66658</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-23T14:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime Error -2147467259</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301580#M66659</link>
      <description>&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;
&lt;P&gt;You might want to look at XLOADCTL system variable. I have had success &lt;BR /&gt;
setting this variable on all my users machines. Sometimes without them knowing &lt;BR /&gt;
it (through code they use or by walking up to there computer and setting it). &lt;BR /&gt;
Once it is set (to 2) overlaying will be in place. Most users have never seen &lt;BR /&gt;
this variable and therefore are unlikely to change it.&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;Regards,&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;Rogue&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE dir="ltr"&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;"xiexieanke" &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:carmen.kuegler@web.de"&amp;gt;carmen.kuegler@web.de&lt;/A&gt;&amp;gt; wrote in &lt;BR /&gt;
  message &lt;A&gt;&lt;BR /&gt;
  href="news:f13a53a.-1@WebX.maYIadrTaRb"&amp;gt;news:f13a53a.-1@WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;Hi, &lt;BR /&gt;
  &lt;BR /&gt;I have attached several XREFs in a drawing. After plotting &lt;BR /&gt;I need to &lt;BR /&gt;
  detach the XREFs. So far I use the following code: &lt;BR /&gt;
  &lt;P&gt;Dim blockObjekt As AcadBlock &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;For Each blockObjekt In ThisDrawing.Blocks &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;if blockObjekt.IsXRef Then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If &lt;BR /&gt;
  blockObjekt.name &amp;lt;&amp;gt; "" Then &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Debug.Print &lt;BR /&gt;
  blockObjekt.name &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ThisDrawing.Blocks.Item(blockObjekt.name).Detach &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End &lt;BR /&gt;
  If &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Next blockObjekt &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;The first XREF is detached, after that I get a Runtime Error -2147467259 &lt;BR /&gt;
  and the routine ends. &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Does anybody know what happens? &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Carmen&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 23 Jan 2003 15:27:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301580#M66659</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-23T15:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime Error -2147467259</title>
      <link>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301581#M66660</link>
      <description>&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;
&lt;P&gt;You might want to look at XLOADCTL system variable. I have had success &lt;BR /&gt;
setting this variable on all my users machines. Sometimes without them knowing &lt;BR /&gt;
it (through code they use or by walking up to there computer and setting it). &lt;BR /&gt;
Once it is set (to 2) overlaying will be in place. Most users have never seen &lt;BR /&gt;
this variable and therefore are unlikely to change it.&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;Regards,&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;Rogue&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE dir="ltr"&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;"xiexieanke" &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:carmen.kuegler@web.de"&amp;gt;carmen.kuegler@web.de&lt;/A&gt;&amp;gt; wrote in &lt;BR /&gt;
  message &lt;A&gt;&lt;BR /&gt;
  href="news:f13a53a.-1@WebX.maYIadrTaRb"&amp;gt;news:f13a53a.-1@WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;Hi, &lt;BR /&gt;
  &lt;BR /&gt;I have attached several XREFs in a drawing. After plotting &lt;BR /&gt;I need to &lt;BR /&gt;
  detach the XREFs. So far I use the following code: &lt;BR /&gt;
  &lt;P&gt;Dim blockObjekt As AcadBlock &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;For Each blockObjekt In ThisDrawing.Blocks &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;if blockObjekt.IsXRef Then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If &lt;BR /&gt;
  blockObjekt.name &amp;lt;&amp;gt; "" Then &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Debug.Print &lt;BR /&gt;
  blockObjekt.name &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ThisDrawing.Blocks.Item(blockObjekt.name).Detach &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End &lt;BR /&gt;
  If &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Next blockObjekt &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;The first XREF is detached, after that I get a Runtime Error -2147467259 &lt;BR /&gt;
  and the routine ends. &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Does anybody know what happens? &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Carmen&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 23 Jan 2003 15:28:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/runtime-error-2147467259/m-p/301581#M66660</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-23T15:28:18Z</dc:date>
    </item>
  </channel>
</rss>

