<?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: GetObject() / CreateObject in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/getobject-createobject/m-p/1011614#M55072</link>
    <description>Ken, &lt;BR /&gt;
&lt;BR /&gt;
Hope your having a good day. Maybe I can help with your questions. &lt;BR /&gt;
&lt;BR /&gt;
#2 &lt;BR /&gt;
&lt;BR /&gt;
When you compile you are seeing the name of your project as defined in your project properties window. The only attribute you will see is Name. Enter what you want your project named. Once you do this you will see in your project window that the name Project1 has changed to your project name. If you don't see any of these "panes" do the following: &lt;BR /&gt;
&lt;BR /&gt;
From the view menu select Project Explorer or the hotkey Ctrl+R. From the same view menu you can also select properties window or hotkey F4. &lt;BR /&gt;
&lt;BR /&gt;
#1 &lt;BR /&gt;
&lt;BR /&gt;
Stop - read your help files for CreateObject and GetObject. &lt;BR /&gt;
&lt;BR /&gt;
CreateObject is a function that creates and returns a reference to an ActiveX object. You really need to read up on this to understand what is meant by an ActiveX object. &lt;BR /&gt;
&lt;BR /&gt;
Lets take starting AutoCAD from a VB exe project. &lt;BR /&gt;
&lt;BR /&gt;
Start a new EXE project &lt;BR /&gt;
&lt;BR /&gt;
Place a command button on the form &lt;BR /&gt;
&lt;BR /&gt;
Double click on the command button you just placed on the form. This will place you in the command button click event. &lt;BR /&gt;
&lt;BR /&gt;
Remember VB6 or VB Classic as we call it is an example of an event driven language. This of course can be debated but I'm being as simple as possible so I won't expand in that direction. &lt;BR /&gt;
&lt;BR /&gt;
Within the Command_Click event place the following code: &lt;BR /&gt;
&lt;BR /&gt;
Dim MyAcadApp As AcadApplication &lt;BR /&gt;
&lt;BR /&gt;
On Error Resume Next &lt;BR /&gt;
&lt;BR /&gt;
' This sets a reference to AutoCAD Application &lt;BR /&gt;
Set MyAcadApp = GetObject(, "AutoCAD.Application") &lt;BR /&gt;
&lt;BR /&gt;
' If the is an error then AutoCAD is not running. If not running you want to CreateObject. &lt;BR /&gt;
&lt;BR /&gt;
If Err Then &lt;BR /&gt;
Err.Clear ' Clear the error if it exists &lt;BR /&gt;
&lt;BR /&gt;
Set MyAcadApp = CreateObject("Autocad.Application") ' This opens the existing running instance of AutoCAD &lt;BR /&gt;
&lt;BR /&gt;
' In the next line your checking for some other error. If one exists take a look at the error via Err (read up) &lt;BR /&gt;
If Err Then &lt;BR /&gt;
MsgBox Err.Description &lt;BR /&gt;
' You've some type of error so you might as well quit here and fix the problem &lt;BR /&gt;
&lt;BR /&gt;
Exit Sub &lt;BR /&gt;
&lt;BR /&gt;
End If ' Close the second (nested) If condition &lt;BR /&gt;
&lt;BR /&gt;
End If ' Close the first if condition &lt;BR /&gt;
&lt;BR /&gt;
' If your this far then look at AutoCAD &lt;BR /&gt;
MyAcadApp.Visible = True &lt;BR /&gt;
&lt;BR /&gt;
End Sub &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
As for your question regarding starting your VB6 exe I would probably use the FindExecute and ShellExecute API functions as one alternative.....but let's not go there right now. &lt;BR /&gt;
&lt;BR /&gt;
Best of luck to ya, hope this helps. &lt;BR /&gt;
&lt;BR /&gt;
Regards, &lt;BR /&gt;
&lt;BR /&gt;
Bob Coward &lt;BR /&gt;
CADS, Inc &lt;BR /&gt;
&lt;BR /&gt;
800-366-0946 &lt;BR /&gt;
bcoward@mindspring.com</description>
    <pubDate>Fri, 23 Apr 2004 14:49:59 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2004-04-23T14:49:59Z</dc:date>
    <item>
      <title>GetObject() / CreateObject</title>
      <link>https://forums.autodesk.com/t5/vba-forum/getobject-createobject/m-p/1011613#M55071</link>
      <description>Hi Group,

Thanks to all for your help in the past.  Here are two more questions.

1.    If I begin a new VB6 application, I see that I can choose Standard EXE
or ActiveX EXE (and others).  If I choose ActiveX EXE does that mean that I
can use GetObject() or CreateObject() from AutoCAD VBA (or any other ActiveX
application for that matter) to create an instance of my VB6 application?

2.    When I compile to EXE my executable always says Project1.exe.  How do
I change this?

Regards,
Ken Hutson
San ANtonio, TX</description>
      <pubDate>Thu, 22 Apr 2004 01:16:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/getobject-createobject/m-p/1011613#M55071</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-04-22T01:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: GetObject() / CreateObject</title>
      <link>https://forums.autodesk.com/t5/vba-forum/getobject-createobject/m-p/1011614#M55072</link>
      <description>Ken, &lt;BR /&gt;
&lt;BR /&gt;
Hope your having a good day. Maybe I can help with your questions. &lt;BR /&gt;
&lt;BR /&gt;
#2 &lt;BR /&gt;
&lt;BR /&gt;
When you compile you are seeing the name of your project as defined in your project properties window. The only attribute you will see is Name. Enter what you want your project named. Once you do this you will see in your project window that the name Project1 has changed to your project name. If you don't see any of these "panes" do the following: &lt;BR /&gt;
&lt;BR /&gt;
From the view menu select Project Explorer or the hotkey Ctrl+R. From the same view menu you can also select properties window or hotkey F4. &lt;BR /&gt;
&lt;BR /&gt;
#1 &lt;BR /&gt;
&lt;BR /&gt;
Stop - read your help files for CreateObject and GetObject. &lt;BR /&gt;
&lt;BR /&gt;
CreateObject is a function that creates and returns a reference to an ActiveX object. You really need to read up on this to understand what is meant by an ActiveX object. &lt;BR /&gt;
&lt;BR /&gt;
Lets take starting AutoCAD from a VB exe project. &lt;BR /&gt;
&lt;BR /&gt;
Start a new EXE project &lt;BR /&gt;
&lt;BR /&gt;
Place a command button on the form &lt;BR /&gt;
&lt;BR /&gt;
Double click on the command button you just placed on the form. This will place you in the command button click event. &lt;BR /&gt;
&lt;BR /&gt;
Remember VB6 or VB Classic as we call it is an example of an event driven language. This of course can be debated but I'm being as simple as possible so I won't expand in that direction. &lt;BR /&gt;
&lt;BR /&gt;
Within the Command_Click event place the following code: &lt;BR /&gt;
&lt;BR /&gt;
Dim MyAcadApp As AcadApplication &lt;BR /&gt;
&lt;BR /&gt;
On Error Resume Next &lt;BR /&gt;
&lt;BR /&gt;
' This sets a reference to AutoCAD Application &lt;BR /&gt;
Set MyAcadApp = GetObject(, "AutoCAD.Application") &lt;BR /&gt;
&lt;BR /&gt;
' If the is an error then AutoCAD is not running. If not running you want to CreateObject. &lt;BR /&gt;
&lt;BR /&gt;
If Err Then &lt;BR /&gt;
Err.Clear ' Clear the error if it exists &lt;BR /&gt;
&lt;BR /&gt;
Set MyAcadApp = CreateObject("Autocad.Application") ' This opens the existing running instance of AutoCAD &lt;BR /&gt;
&lt;BR /&gt;
' In the next line your checking for some other error. If one exists take a look at the error via Err (read up) &lt;BR /&gt;
If Err Then &lt;BR /&gt;
MsgBox Err.Description &lt;BR /&gt;
' You've some type of error so you might as well quit here and fix the problem &lt;BR /&gt;
&lt;BR /&gt;
Exit Sub &lt;BR /&gt;
&lt;BR /&gt;
End If ' Close the second (nested) If condition &lt;BR /&gt;
&lt;BR /&gt;
End If ' Close the first if condition &lt;BR /&gt;
&lt;BR /&gt;
' If your this far then look at AutoCAD &lt;BR /&gt;
MyAcadApp.Visible = True &lt;BR /&gt;
&lt;BR /&gt;
End Sub &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
As for your question regarding starting your VB6 exe I would probably use the FindExecute and ShellExecute API functions as one alternative.....but let's not go there right now. &lt;BR /&gt;
&lt;BR /&gt;
Best of luck to ya, hope this helps. &lt;BR /&gt;
&lt;BR /&gt;
Regards, &lt;BR /&gt;
&lt;BR /&gt;
Bob Coward &lt;BR /&gt;
CADS, Inc &lt;BR /&gt;
&lt;BR /&gt;
800-366-0946 &lt;BR /&gt;
bcoward@mindspring.com</description>
      <pubDate>Fri, 23 Apr 2004 14:49:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/getobject-createobject/m-p/1011614#M55072</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-04-23T14:49:59Z</dc:date>
    </item>
  </channel>
</rss>

