<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>[VBA] Error 424:  Object Required</title><link>https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/105540/vba-error-424-object-required</link><description>Can anyone please let me know why my code is not working? I keep receiving Error 424: Object Required. I&amp;#39;m pretty new to VBA and coding so it might be something very simple. This is what I would like my code to do: 
 
 There are text elements in a level</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: [VBA] Error 424:  Object Required</title><link>https://communities.bentley.com/thread/317888?ContentTypeID=1</link><pubDate>Fri, 20 Mar 2015 15:49:48 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:b739875e-7832-4bd7-bbbc-3f1387fc310b</guid><dc:creator>Jeff Dragowski</dc:creator><description>Nevermind, I got it!  Instead of .Scan I am now using .GetSelectedElements .&lt;br /&gt;
&lt;br /&gt;
Thanks for all your help!&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [VBA] Error 424:  Object Required</title><link>https://communities.bentley.com/thread/317886?ContentTypeID=1</link><pubDate>Fri, 20 Mar 2015 15:40:09 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:d8f9cb03-3d29-4297-ac74-096711f9465d</guid><dc:creator>Jeff Dragowski</dc:creator><description>Jon,&lt;br /&gt;
        First, thanks for all the help.  I&amp;#39;ve looked up every word of code you have helped me with so far in the MicroStationVBA.chm and I&amp;#39;ve really developed a good understanding of what is happening when I run this VBA.  But there is one thing that I cannot get around, I cannot select a text element, run the macro, and have that text element attach to the general URL in the code.  Instead, only the most recently created text element will attach itself to the general URL in the code.  Example:  I use the Place Text tool to create a text element that displays the following text, TEST, then I select a different text element and run the VBA and a get a link attached to that text element that reads www.generalURL.com/TEST.  I&amp;#39;ve searched the VBA Help index high and low looking for a way to parse out only the text of the element that I currently have highlighted.  I keep delving deeper and deeper into selection set tutorials, but I can&amp;#39;t seem to find anything.  Here is the code as it is:&lt;br /&gt;
&lt;br /&gt;
Sub Init()&lt;br /&gt;
    Dim ee As ElementEnumerator&lt;br /&gt;
    Set ee = ActiveModelReference.Scan&lt;br /&gt;
    Do While ee.MoveNext&lt;br /&gt;
    Dim oElement As Element&lt;br /&gt;
    Set oElement = ee.Current&lt;br /&gt;
    If oElement.IsTextElement Then&lt;br /&gt;
        Dim oTextElement As TextElement&lt;br /&gt;
        Set oTextElement = oElement.AsTextElement&lt;br /&gt;
        Debug.Print &amp;quot;Text=&amp;quot; &amp;amp; oTextElement.Text&lt;br /&gt;
    End If&lt;br /&gt;
Loop&lt;br /&gt;
    Dim content As String&lt;br /&gt;
    content = oTextElement.Text&lt;br /&gt;
    CreateLink content&lt;br /&gt;
End Sub&lt;br /&gt;
Sub CreateLink(ByVal content As String)&lt;br /&gt;
    Dim strURL As String&lt;br /&gt;
    strURL = &amp;quot;&lt;a href="http://www.google.com"&gt;http://www.google.com&lt;/a&gt;&amp;quot; &amp;amp; &amp;quot;/&amp;quot; &amp;amp; content&lt;br /&gt;
    Debug.Print &amp;quot;My URL=&amp;quot; &amp;amp; strURL&lt;br /&gt;
    CadInputQueue.SendKeyin &amp;quot;ELEMENT CREATE LINK URL &amp;quot; &amp;amp; strURL&lt;br /&gt;
End Sub&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Do you see any reason why this is happening?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [VBA] Error 424:  Object Required</title><link>https://communities.bentley.com/thread/317828?ContentTypeID=1</link><pubDate>Fri, 20 Mar 2015 07:00:10 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:e6e76b83-b940-4ce1-b139-c0a520dad898</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Jeff,&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Jeff Dragowski&amp;quot;]I&amp;#39;m pretty new to VBA and coding[/quote]&lt;/p&gt;
&lt;p&gt;The problem is not you are new to VBA, because we were (and for sure will be again) new to some topic ;-)&lt;/p&gt;
&lt;p&gt;But what is the problem is it seems you didn&amp;#39;t pass any VBA learning, so you don&amp;#39;t have basic knowledge how VBA works and how to create VBA apps, and you are trying to use MicroStation VBA, which adds another magnitude of complexity. In other worlds, you want to fly before you know how to walk.&lt;/p&gt;
&lt;p&gt;I asked you already in another thread and you have not answered it: Did you read &lt;a target="_blank" href="http://www.bentley.com/en-US/Training/Products/Resources/Books/Learning+MicroStation+VBA.htm"&gt;Learning MicroStation VBA&lt;/a&gt; book? This is mandatory reading for anybody who wish to start with MicroStation VBA. It starts step by step from a ground, so it requires and expects only basic knowledge of VBA. It can make your coding effort much easier and will provide you answers for many your questions and problems.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [VBA] Error 424:  Object Required</title><link>https://communities.bentley.com/thread/317793?ContentTypeID=1</link><pubDate>Thu, 19 Mar 2015 19:06:35 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:a25445a1-fa88-43fd-9962-9756fa2949a4</guid><dc:creator>Jon Summers</dc:creator><description>&lt;p&gt;[quote user=&amp;quot;Jeff Dragowski&amp;quot;]Dim ee As ElementEnumerator&lt;br /&gt; Dim oText As TextElement&lt;br /&gt; Set oText = ee.Current.AsTextElement&lt;br /&gt; [/quote]&lt;/p&gt;
&lt;p&gt;You&amp;#39;ve declared a variable named &lt;span style="font-family:courier new,courier;"&gt;ee&lt;/span&gt;.&amp;nbsp; It&amp;#39;s a reference to a class of type &lt;span style="font-family:courier new,courier;"&gt;ElementEnumerator&lt;/span&gt;.&amp;nbsp; Right now, you haven&amp;#39;t initialised that object: it&amp;#39;s an empty chunk of memory.&amp;nbsp; That explains the error message.&lt;/p&gt;
&lt;p&gt;An &lt;span style="font-family:courier new,courier;"&gt;ElementEnumerator&lt;/span&gt; is used to enumerate elements.&amp;nbsp; The question is &amp;quot;What elements do you want to enumerate?&amp;quot;&amp;nbsp; Often, you want to scan a DGN model to examine its graphic elements.&amp;nbsp; The Scan method of ModelReference does exactly that and returns a valid ElementEnumerator.&amp;nbsp; Look that up in VBA help, and write something like this:&lt;/p&gt;
&lt;pre class="brush: vb; fontsize: 100; first-line: 1; "&gt;Set ee = ActiveModelReference.Scan
Do While ee.MoveNext
  Dim oElement As Element
  Set oElement = ee.Current
  If oElement.IsTextElement Then
    Dim oTextElement As TextElement
    Set oTextElement = oElement.AsTextElement
    &amp;#39;  Now you can use the properties and methods of TextElement
    Debug.Print &amp;quot;Text=&amp;quot; &amp;amp; oTextElement.Text
  EndIf
Loop&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [VBA] Error 424:  Object Required</title><link>https://communities.bentley.com/thread/317787?ContentTypeID=1</link><pubDate>Thu, 19 Mar 2015 18:35:34 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:a71dc6cb-f2fe-4ee0-b5da-68a5d92f4759</guid><dc:creator>Jeff Dragowski</dc:creator><description>Thank you for the quick tip Robert.&lt;br /&gt;
&lt;br /&gt;
Here is what I think you are saying is the solution (with this change I am now getting a different error though):&lt;br /&gt;
&lt;br /&gt;
Sub Init()&lt;br /&gt;
  Dim ee As ElementEnumerator&lt;br /&gt;
  Dim oText As TextElement&lt;br /&gt;
  Set oText = ee.Current.AsTextElement      &amp;#39;The error is now occurring here (Run-Time error &amp;#39;91&amp;#39;:  Object variable or With block variable not set&lt;br /&gt;
&lt;br /&gt;
  Dim content As String&lt;br /&gt;
  content = oText.Text&lt;br /&gt;
  CreateLink content&lt;br /&gt;
End Sub&lt;br /&gt;
Sub CreateLink(ByVal content As String)&lt;br /&gt;
  Dim strURL As String&lt;br /&gt;
  strURL = &amp;quot;&lt;a href="http://www.google.com"&gt;http://www.google.com&lt;/a&gt;&amp;quot; &amp;amp; &amp;quot;/&amp;quot; &amp;amp; content&lt;br /&gt;
  Debug.Print &amp;quot;My URL=&amp;quot; &amp;amp; strURL&lt;br /&gt;
  CadInputQueue.SendKeyin &amp;quot;ELEMENT CREATE LINK URL &amp;quot; &amp;amp; strURL&lt;br /&gt;
End Sub&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [VBA] Error 424:  Object Required</title><link>https://communities.bentley.com/thread/317785?ContentTypeID=1</link><pubDate>Thu, 19 Mar 2015 18:27:35 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:cf3d941d-8b9e-4816-83a9-54b31ccaa4aa</guid><dc:creator>Robert Schwenn</dc:creator><description>&lt;p&gt;You should see the line which causes the error and tell it us...&lt;/p&gt;
&lt;p&gt;But this case seems pretty simple: Neither You&amp;#39;ve declared the variable &lt;em&gt;&lt;strong&gt;ElementEnumerator&lt;/strong&gt; &lt;/em&gt;nor did You assign any value to it - at least not in the code we can see here. &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Robert&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>