<?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: in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/why-doesn-t-this-work-put-me-out-of-my-misery/m-p/332901#M89176</link>
    <description>Bang!&lt;BR /&gt;
&lt;BR /&gt;
Dale, it would be a bad idea to attempt to explicitly force arbitrary values&lt;BR /&gt;
for the variants with the error handler. After all, those subs could be used&lt;BR /&gt;
in the same project for many different XRecords.&lt;BR /&gt;
&lt;BR /&gt;
Your error handler should be in the calling procedures.&lt;BR /&gt;
&lt;BR /&gt;
Public Sub GetXrecord(dName As String, keyName As String, xType, xData)&lt;BR /&gt;
    On Error Resume Next ' &amp;lt;- Note change from online code!&lt;BR /&gt;
    Dim dic As AcadDictionary, xrec As AcadXRecord&lt;BR /&gt;
    Set dic = ThisDrawing.Dictionaries(dName)&lt;BR /&gt;
    Set xrec = dic.Item(keyName)&lt;BR /&gt;
    xrec.GetXRecordData xType, xData&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function HasElements(ByVal ArrayToCheck As Variant) As Boolean&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  HasElements = (LBound(ArrayToCheck) &amp;lt;= UBound(ArrayToCheck))&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Public Sub Test()&lt;BR /&gt;
  Dim MyType, MyData&lt;BR /&gt;
  GetXrecord "MW Drawing Info", "PrimarySF", MyType, MyData&lt;BR /&gt;
  If HasElements(MyType) Then&lt;BR /&gt;
    Debug.Print "Found data."&lt;BR /&gt;
  Else&lt;BR /&gt;
   Debug.Print "No data!"&lt;BR /&gt;
  End If&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
--&lt;BR /&gt;
R. Robert Bell, MCSE&lt;BR /&gt;
www.AcadX.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"Dale Levesque" &lt;DALE at="" dynamicwindows.com=""&gt; wrote in message&lt;BR /&gt;
news:29DD2EF030E42DC21822A304CEAB1A35@in.WebX.maYIadrTaRb...&lt;BR /&gt;
|         WriteXrecord "Test", "SectionLst", 300, "((0) (1 2 3))"&lt;BR /&gt;
|         GetXrecord "Test", "SectionLst", XRecordDataType, gv_SectionList&lt;BR /&gt;
|&lt;BR /&gt;
| Public Sub GetXrecord(dName As String, keyName As String, xType, xData)&lt;BR /&gt;
|&lt;BR /&gt;
|     On Error GoTo ErrHandler&lt;BR /&gt;
|&lt;BR /&gt;
|     Dim dic As AcadDictionary, xrec As AcadXRecord&lt;BR /&gt;
|&lt;BR /&gt;
|     Set xrec = ThisDrawing.Dictionaries.Item(dName)&lt;BR /&gt;
|     xrec.GetXRecordData xType, xData&lt;BR /&gt;
|&lt;BR /&gt;
|     Exit Sub&lt;BR /&gt;
|&lt;BR /&gt;
| ErrHandler:&lt;BR /&gt;
|&lt;BR /&gt;
|     xType = Array(300)&lt;BR /&gt;
|     xData = Array("")&lt;BR /&gt;
|&lt;BR /&gt;
| End Sub&lt;BR /&gt;
|&lt;BR /&gt;
| Public Sub GetXrecord(dName As String, keyName As String, xType, xData)&lt;BR /&gt;
|&lt;BR /&gt;
|     On Error GoTo ErrHandler&lt;BR /&gt;
|&lt;BR /&gt;
|     Dim dic As AcadDictionary, xrec As AcadXRecord&lt;BR /&gt;
|&lt;BR /&gt;
|     Set xrec = ThisDrawing.Dictionaries.Item(dName)&lt;BR /&gt;
|     xrec.GetXRecordData xType, xData&lt;BR /&gt;
|&lt;BR /&gt;
|     Exit Sub&lt;BR /&gt;
|&lt;BR /&gt;
| ErrHandler:&lt;BR /&gt;
|&lt;BR /&gt;
|     xType = Array(300)&lt;BR /&gt;
|     xData = Array("")&lt;BR /&gt;
|&lt;BR /&gt;
| End Sub&lt;BR /&gt;
|&lt;BR /&gt;
| These are routines found at Franks site by the way.&lt;BR /&gt;
| The "Set xrec ..." line in GetXrecord fails even though I can see it in&lt;BR /&gt;
the&lt;BR /&gt;
| dictionaries collection using the watch window.&lt;BR /&gt;
|&lt;BR /&gt;
| Dale&lt;BR /&gt;
|&lt;BR /&gt;
|&lt;/DALE&gt;</description>
    <pubDate>Tue, 14 Jan 2003 10:11:45 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2003-01-14T10:11:45Z</dc:date>
    <item>
      <title>Why doesn't this work? Put me out of my misery!</title>
      <link>https://forums.autodesk.com/t5/vba-forum/why-doesn-t-this-work-put-me-out-of-my-misery/m-p/332898#M89173</link>
      <description>I have been struggling for a week, on and off, with both AutoLisp and now&lt;BR /&gt;
VBA, to write a routine to rotate a layout (pspace objects including&lt;BR /&gt;
viewports and views) through 90 degrees. I am a novice at both languages, so&lt;BR /&gt;
excuse any crudities in the routine below.&lt;BR /&gt;
&lt;BR /&gt;
The macro works right up to the last point, which is to restore the centre&lt;BR /&gt;
of the view. I just cannot get it to work (I've tried using Direction and&lt;BR /&gt;
Target properties). What am I doing wrong???&lt;BR /&gt;
&lt;BR /&gt;
thanks!&lt;BR /&gt;
&lt;BR /&gt;
Sub RotateLayout()&lt;BR /&gt;
&lt;BR /&gt;
On Error GoTo Errorhandler&lt;BR /&gt;
&lt;BR /&gt;
    Dim ssetObj As AcadSelectionSet&lt;BR /&gt;
    Set ssetObj = ThisDrawing.SelectionSets.Add("SSET")&lt;BR /&gt;
&lt;BR /&gt;
    ssetObj.SelectOnScreen&lt;BR /&gt;
&lt;BR /&gt;
    Dim objCount As Integer&lt;BR /&gt;
    Dim I As Integer&lt;BR /&gt;
&lt;BR /&gt;
    objCount = ssetObj.Count&lt;BR /&gt;
&lt;BR /&gt;
    Dim pspaceObj As AcadEntity&lt;BR /&gt;
    Dim basept As Variant&lt;BR /&gt;
    Dim rotAngle As Double&lt;BR /&gt;
    Dim origin(0 To 2) As Double&lt;BR /&gt;
&lt;BR /&gt;
    origin(0) = 0#&lt;BR /&gt;
    origin(1) = 0#&lt;BR /&gt;
    origin(2) = 0#&lt;BR /&gt;
    rotAngle = -1.5708&lt;BR /&gt;
    basept = ThisDrawing.Utility.GetPoint(, "Enter the point which will be&lt;BR /&gt;
at 0,0 after rotation: ")&lt;BR /&gt;
&lt;BR /&gt;
    For I = 0 To objCount - 1&lt;BR /&gt;
        Set pspaceObj = ssetObj.Item(I)&lt;BR /&gt;
        pspaceObj.Move basept, origin&lt;BR /&gt;
        pspaceObj.Rotate origin, rotAngle&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    Dim vpObj As AcadPViewport&lt;BR /&gt;
    Dim currWidth, currHeight As Double&lt;BR /&gt;
    Dim vpTarget As Variant&lt;BR /&gt;
    Dim custScale, stdScale As Double&lt;BR /&gt;
&lt;BR /&gt;
For I = 0 To objCount - 1&lt;BR /&gt;
    Set pspaceObj = ssetObj.Item(I)&lt;BR /&gt;
       If (pspaceObj.ObjectName = "AcDbViewport") Then&lt;BR /&gt;
          Set vpObj = ssetObj.Item(I)&lt;BR /&gt;
&lt;BR /&gt;
'get current settings&lt;BR /&gt;
          currWidth = vpObj.Width&lt;BR /&gt;
          currHeight = vpObj.Height&lt;BR /&gt;
          vpTarget = vpObj.Target&lt;BR /&gt;
          custScale = vpObj.CustomScale&lt;BR /&gt;
          stdScale = vpObj.StandardScale&lt;BR /&gt;
&lt;BR /&gt;
'swap width/height&lt;BR /&gt;
          vpObj.Width = currHeight&lt;BR /&gt;
          vpObj.Height = currWidth&lt;BR /&gt;
          vpObj.update&lt;BR /&gt;
&lt;BR /&gt;
'go to mspace, turn UCS, set plan, return UCS&lt;BR /&gt;
          ThisDrawing.MSpace = True&lt;BR /&gt;
          ThisDrawing.ActivePViewport = vpObj&lt;BR /&gt;
          ThisDrawing.SendCommand "_ucs" &amp;amp; vbCr &amp;amp; "z" &amp;amp; vbCr &amp;amp; "90" &amp;amp; vbCr&lt;BR /&gt;
          ThisDrawing.SendCommand "_plan" &amp;amp; vbCr &amp;amp; "current" &amp;amp; vbCr&lt;BR /&gt;
          ThisDrawing.SendCommand "ucs" &amp;amp; vbCr &amp;amp; "prev" &amp;amp; vbCr&lt;BR /&gt;
          ThisDrawing.MSpace = False&lt;BR /&gt;
&lt;BR /&gt;
'turn display off while returning previous settings then turn back on&lt;BR /&gt;
&lt;BR /&gt;
          vpObj.Display False&lt;BR /&gt;
          vpObj.StandardScale = stdScale&lt;BR /&gt;
          vpObj.CustomScale = custScale&lt;BR /&gt;
          vpObj.Target = vpTarget&lt;BR /&gt;
          vpObj.Display True&lt;BR /&gt;
          vpObj.Update&lt;BR /&gt;
          ThisDrawing.Regen acAllViewports&lt;BR /&gt;
&lt;BR /&gt;
        End If&lt;BR /&gt;
&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
Errorhandler:&lt;BR /&gt;
&lt;BR /&gt;
   ssetObj.Delete&lt;BR /&gt;
   ZoomExtents&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
-------------------------------------------------&lt;BR /&gt;
Keith Pocock&lt;BR /&gt;
mailto:keithlp@breathemail.net</description>
      <pubDate>Sat, 25 Nov 2000 14:20:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/why-doesn-t-this-work-put-me-out-of-my-misery/m-p/332898#M89173</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2000-11-25T14:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't this work? Put me out of my misery!</title>
      <link>https://forums.autodesk.com/t5/vba-forum/why-doesn-t-this-work-put-me-out-of-my-misery/m-p/332899#M89174</link>
      <description>Update -&lt;BR /&gt;
&lt;BR /&gt;
What exactly is the .Target property?  I thought it was the VB version of&lt;BR /&gt;
the view centre (ie. the modelspace view contained within the paperspace&lt;BR /&gt;
viewport),   but it seems that it is not.&lt;BR /&gt;
&lt;BR /&gt;
If I query a viewport the target is ALWAYS 0,0 unless it has already been&lt;BR /&gt;
specfically set by some previous VB code. Furthermore, I have now got the&lt;BR /&gt;
view to change by altering the value of the target property of the viewport,&lt;BR /&gt;
but the coordinate passed does not become the centre of the view.&lt;BR /&gt;
&lt;BR /&gt;
Really confused now. How do you query/set the view shown through a&lt;BR /&gt;
PViewport?&lt;BR /&gt;
&lt;BR /&gt;
thanks&lt;BR /&gt;
&lt;BR /&gt;
"Keith Pocock" &lt;KEITHP&gt; wrote in message&lt;BR /&gt;
news:1E20A4CCAA6E59DBDFE152626F066CAB@in.WebX.SaUCah8kaAW...&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; I have been struggling for a week, on and off, with both AutoLisp and now&lt;BR /&gt;
&amp;gt; VBA, to write a routine to rotate a layout (pspace objects including&lt;BR /&gt;
&amp;gt; viewports and views) through 90 degrees. I am a novice at both languages,&lt;BR /&gt;
so&lt;BR /&gt;
&amp;gt; excuse any crudities in the routine below.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; The macro works right up to the last point, which is to restore the centre&lt;BR /&gt;
&amp;gt; of the view. I just cannot get it to work (I've tried using Direction and&lt;BR /&gt;
&amp;gt; Target properties). What am I doing wrong???&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; thanks!&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Sub RotateLayout()&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; On Error GoTo Errorhandler&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Dim ssetObj As AcadSelectionSet&lt;BR /&gt;
&amp;gt;     Set ssetObj = ThisDrawing.SelectionSets.Add("SSET")&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     ssetObj.SelectOnScreen&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Dim objCount As Integer&lt;BR /&gt;
&amp;gt;     Dim I As Integer&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     objCount = ssetObj.Count&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Dim pspaceObj As AcadEntity&lt;BR /&gt;
&amp;gt;     Dim basept As Variant&lt;BR /&gt;
&amp;gt;     Dim rotAngle As Double&lt;BR /&gt;
&amp;gt;     Dim origin(0 To 2) As Double&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     origin(0) = 0#&lt;BR /&gt;
&amp;gt;     origin(1) = 0#&lt;BR /&gt;
&amp;gt;     origin(2) = 0#&lt;BR /&gt;
&amp;gt;     rotAngle = -1.5708&lt;BR /&gt;
&amp;gt;     basept = ThisDrawing.Utility.GetPoint(, "Enter the point which will be&lt;BR /&gt;
&amp;gt; at 0,0 after rotation: ")&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     For I = 0 To objCount - 1&lt;BR /&gt;
&amp;gt;         Set pspaceObj = ssetObj.Item(I)&lt;BR /&gt;
&amp;gt;         pspaceObj.Move basept, origin&lt;BR /&gt;
&amp;gt;         pspaceObj.Rotate origin, rotAngle&lt;BR /&gt;
&amp;gt;     Next&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Dim vpObj As AcadPViewport&lt;BR /&gt;
&amp;gt;     Dim currWidth, currHeight As Double&lt;BR /&gt;
&amp;gt;     Dim vpTarget As Variant&lt;BR /&gt;
&amp;gt;     Dim custScale, stdScale As Double&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; For I = 0 To objCount - 1&lt;BR /&gt;
&amp;gt;     Set pspaceObj = ssetObj.Item(I)&lt;BR /&gt;
&amp;gt;        If (pspaceObj.ObjectName = "AcDbViewport") Then&lt;BR /&gt;
&amp;gt;           Set vpObj = ssetObj.Item(I)&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; 'get current settings&lt;BR /&gt;
&amp;gt;           currWidth = vpObj.Width&lt;BR /&gt;
&amp;gt;           currHeight = vpObj.Height&lt;BR /&gt;
&amp;gt;           vpTarget = vpObj.Target&lt;BR /&gt;
&amp;gt;           custScale = vpObj.CustomScale&lt;BR /&gt;
&amp;gt;           stdScale = vpObj.StandardScale&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; 'swap width/height&lt;BR /&gt;
&amp;gt;           vpObj.Width = currHeight&lt;BR /&gt;
&amp;gt;           vpObj.Height = currWidth&lt;BR /&gt;
&amp;gt;           vpObj.update&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; 'go to mspace, turn UCS, set plan, return UCS&lt;BR /&gt;
&amp;gt;           ThisDrawing.MSpace = True&lt;BR /&gt;
&amp;gt;           ThisDrawing.ActivePViewport = vpObj&lt;BR /&gt;
&amp;gt;           ThisDrawing.SendCommand "_ucs" &amp;amp; vbCr &amp;amp; "z" &amp;amp; vbCr &amp;amp; "90" &amp;amp; vbCr&lt;BR /&gt;
&amp;gt;           ThisDrawing.SendCommand "_plan" &amp;amp; vbCr &amp;amp; "current" &amp;amp; vbCr&lt;BR /&gt;
&amp;gt;           ThisDrawing.SendCommand "ucs" &amp;amp; vbCr &amp;amp; "prev" &amp;amp; vbCr&lt;BR /&gt;
&amp;gt;           ThisDrawing.MSpace = False&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; 'turn display off while returning previous settings then turn back on&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;           vpObj.Display False&lt;BR /&gt;
&amp;gt;           vpObj.StandardScale = stdScale&lt;BR /&gt;
&amp;gt;           vpObj.CustomScale = custScale&lt;BR /&gt;
&amp;gt;           vpObj.Target = vpTarget&lt;BR /&gt;
&amp;gt;           vpObj.Display True&lt;BR /&gt;
&amp;gt;           vpObj.Update&lt;BR /&gt;
&amp;gt;           ThisDrawing.Regen acAllViewports&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;         End If&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Next&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Errorhandler:&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;    ssetObj.Delete&lt;BR /&gt;
&amp;gt;    ZoomExtents&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; End Sub&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; -------------------------------------------------&lt;BR /&gt;
&amp;gt; Keith Pocock&lt;BR /&gt;
&amp;gt; mailto:keithlp@breathemail.net&lt;BR /&gt;
&amp;gt;&lt;/KEITHP&gt;</description>
      <pubDate>Sun, 26 Nov 2000 14:21:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/why-doesn-t-this-work-put-me-out-of-my-misery/m-p/332899#M89174</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2000-11-26T14:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't this work? Put me out of my misery!</title>
      <link>https://forums.autodesk.com/t5/vba-forum/why-doesn-t-this-work-put-me-out-of-my-misery/m-p/332900#M89175</link>
      <description>WriteXrecord "Test", "SectionLst", 300, "((0) (1 2 3))"&lt;BR /&gt;
        GetXrecord "Test", "SectionLst", XRecordDataType, gv_SectionList&lt;BR /&gt;
&lt;BR /&gt;
Public Sub GetXrecord(dName As String, keyName As String, xType, xData)&lt;BR /&gt;
&lt;BR /&gt;
    On Error GoTo ErrHandler&lt;BR /&gt;
&lt;BR /&gt;
    Dim dic As AcadDictionary, xrec As AcadXRecord&lt;BR /&gt;
&lt;BR /&gt;
    Set xrec = ThisDrawing.Dictionaries.Item(dName)&lt;BR /&gt;
    xrec.GetXRecordData xType, xData&lt;BR /&gt;
&lt;BR /&gt;
    Exit Sub&lt;BR /&gt;
&lt;BR /&gt;
ErrHandler:&lt;BR /&gt;
&lt;BR /&gt;
    xType = Array(300)&lt;BR /&gt;
    xData = Array("")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Public Sub GetXrecord(dName As String, keyName As String, xType, xData)&lt;BR /&gt;
&lt;BR /&gt;
    On Error GoTo ErrHandler&lt;BR /&gt;
&lt;BR /&gt;
    Dim dic As AcadDictionary, xrec As AcadXRecord&lt;BR /&gt;
&lt;BR /&gt;
    Set xrec = ThisDrawing.Dictionaries.Item(dName)&lt;BR /&gt;
    xrec.GetXRecordData xType, xData&lt;BR /&gt;
&lt;BR /&gt;
    Exit Sub&lt;BR /&gt;
&lt;BR /&gt;
ErrHandler:&lt;BR /&gt;
&lt;BR /&gt;
    xType = Array(300)&lt;BR /&gt;
    xData = Array("")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
These are routines found at Franks site by the way.&lt;BR /&gt;
The "Set xrec ..." line in GetXrecord fails even though I can see it in the&lt;BR /&gt;
dictionaries collection using the watch window.&lt;BR /&gt;
&lt;BR /&gt;
Dale</description>
      <pubDate>Mon, 13 Jan 2003 16:18:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/why-doesn-t-this-work-put-me-out-of-my-misery/m-p/332900#M89175</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-13T16:18:48Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/why-doesn-t-this-work-put-me-out-of-my-misery/m-p/332901#M89176</link>
      <description>Bang!&lt;BR /&gt;
&lt;BR /&gt;
Dale, it would be a bad idea to attempt to explicitly force arbitrary values&lt;BR /&gt;
for the variants with the error handler. After all, those subs could be used&lt;BR /&gt;
in the same project for many different XRecords.&lt;BR /&gt;
&lt;BR /&gt;
Your error handler should be in the calling procedures.&lt;BR /&gt;
&lt;BR /&gt;
Public Sub GetXrecord(dName As String, keyName As String, xType, xData)&lt;BR /&gt;
    On Error Resume Next ' &amp;lt;- Note change from online code!&lt;BR /&gt;
    Dim dic As AcadDictionary, xrec As AcadXRecord&lt;BR /&gt;
    Set dic = ThisDrawing.Dictionaries(dName)&lt;BR /&gt;
    Set xrec = dic.Item(keyName)&lt;BR /&gt;
    xrec.GetXRecordData xType, xData&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function HasElements(ByVal ArrayToCheck As Variant) As Boolean&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  HasElements = (LBound(ArrayToCheck) &amp;lt;= UBound(ArrayToCheck))&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Public Sub Test()&lt;BR /&gt;
  Dim MyType, MyData&lt;BR /&gt;
  GetXrecord "MW Drawing Info", "PrimarySF", MyType, MyData&lt;BR /&gt;
  If HasElements(MyType) Then&lt;BR /&gt;
    Debug.Print "Found data."&lt;BR /&gt;
  Else&lt;BR /&gt;
   Debug.Print "No data!"&lt;BR /&gt;
  End If&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
--&lt;BR /&gt;
R. Robert Bell, MCSE&lt;BR /&gt;
www.AcadX.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"Dale Levesque" &lt;DALE at="" dynamicwindows.com=""&gt; wrote in message&lt;BR /&gt;
news:29DD2EF030E42DC21822A304CEAB1A35@in.WebX.maYIadrTaRb...&lt;BR /&gt;
|         WriteXrecord "Test", "SectionLst", 300, "((0) (1 2 3))"&lt;BR /&gt;
|         GetXrecord "Test", "SectionLst", XRecordDataType, gv_SectionList&lt;BR /&gt;
|&lt;BR /&gt;
| Public Sub GetXrecord(dName As String, keyName As String, xType, xData)&lt;BR /&gt;
|&lt;BR /&gt;
|     On Error GoTo ErrHandler&lt;BR /&gt;
|&lt;BR /&gt;
|     Dim dic As AcadDictionary, xrec As AcadXRecord&lt;BR /&gt;
|&lt;BR /&gt;
|     Set xrec = ThisDrawing.Dictionaries.Item(dName)&lt;BR /&gt;
|     xrec.GetXRecordData xType, xData&lt;BR /&gt;
|&lt;BR /&gt;
|     Exit Sub&lt;BR /&gt;
|&lt;BR /&gt;
| ErrHandler:&lt;BR /&gt;
|&lt;BR /&gt;
|     xType = Array(300)&lt;BR /&gt;
|     xData = Array("")&lt;BR /&gt;
|&lt;BR /&gt;
| End Sub&lt;BR /&gt;
|&lt;BR /&gt;
| Public Sub GetXrecord(dName As String, keyName As String, xType, xData)&lt;BR /&gt;
|&lt;BR /&gt;
|     On Error GoTo ErrHandler&lt;BR /&gt;
|&lt;BR /&gt;
|     Dim dic As AcadDictionary, xrec As AcadXRecord&lt;BR /&gt;
|&lt;BR /&gt;
|     Set xrec = ThisDrawing.Dictionaries.Item(dName)&lt;BR /&gt;
|     xrec.GetXRecordData xType, xData&lt;BR /&gt;
|&lt;BR /&gt;
|     Exit Sub&lt;BR /&gt;
|&lt;BR /&gt;
| ErrHandler:&lt;BR /&gt;
|&lt;BR /&gt;
|     xType = Array(300)&lt;BR /&gt;
|     xData = Array("")&lt;BR /&gt;
|&lt;BR /&gt;
| End Sub&lt;BR /&gt;
|&lt;BR /&gt;
| These are routines found at Franks site by the way.&lt;BR /&gt;
| The "Set xrec ..." line in GetXrecord fails even though I can see it in&lt;BR /&gt;
the&lt;BR /&gt;
| dictionaries collection using the watch window.&lt;BR /&gt;
|&lt;BR /&gt;
| Dale&lt;BR /&gt;
|&lt;BR /&gt;
|&lt;/DALE&gt;</description>
      <pubDate>Tue, 14 Jan 2003 10:11:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/why-doesn-t-this-work-put-me-out-of-my-misery/m-p/332901#M89176</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-01-14T10:11:45Z</dc:date>
    </item>
  </channel>
</rss>

