PDA

View Full Version : Set x = CreateObject()



clarksonneo
08-19-2011, 02:24 AM
Hi,

I know that Excel macro can control the things in other software or application.

I understand the code Set x = CreateObject(???)

I have seen a range of examples:
CreateObject("Word.Application")
CreateObject("Access.Application", "MyServer1")
CreateObject("Scripting.FileSystemObject")
CreateObject("Shell.Application")

However, I don't know what else I can create as an object for Excel.

Could you please show me the list for all possible object that the Excel can create?
Ie, the list which contains all objects for using the code createobject().

Thanks

mancubus
08-19-2011, 02:33 AM
hi...

http://www.ozgrid.com/forum/showthread.php?t=74932&page=1

http://www.yogeshguptaonline.com/2009/03/macros-in-excel-learn-excel-vba-objects.html

http://www.dicks-blog.com/archives/2004/04/23/beginning-vba-objects-properties-and-methods/

http://msdn.microsoft.com/en-us/library/aa189754(v=office.10).aspx

JP2112
08-19-2011, 05:41 AM
I don't think that is even possible. You're better off trying to solve a specific problem and looking for the class name then.

Kenneth Hobs
08-19-2011, 06:44 AM
CreateObject() and GetObject() methods are late binding methods. Early binding methods are needed for the VBE's intellisense to work. Intellisense makes it easier to view the methods and properties for the bound object. After you type the object variable and a period, intellisense goes to work.

To see all of the objects that you can set an early bound reference to, in the VBE, select menus Tools > References...

Not only are there new programs developed every day, you can create your own objects in programming languages like c++, c#, vb.net and so on, so a list of these things would never end.

For more details about binding, see: http://support.microsoft.com/kb/245115

JP2112
08-19-2011, 07:05 AM
CreateObject and GetObject are methods for getting an object reference; they aren't exclusively late bound methods. How you declare an object determines whether it is late or early bound, not how you instantiate it. For example, both of these are early bound references because the object is declared as a specific type:


Dim oExcel As Excel.Application
Set oExcel = CreateObject("Excel.Application")

Dim oExcel As Excel.Application
Set oExcel = New Excel.Application


You can see that if you browse the article in the link you provided.

I always use CreateObject because that way, if I want to switch from early to late bound (for example, after taking advantage of Intellisense to write code), I only have to change one line of code (not two).

Bob Phillips
08-19-2011, 07:41 AM
CreateObject and GetObject are methods for getting an object reference; they aren't exclusively late bound methods. How you declare an object determines whether it is late or early bound, not how you instantiate it.

Hurray, someone talking sense at last re late binding.

clarksonneo
08-19-2011, 10:02 AM
I don't think that is even possible. You're better off trying to solve a specific problem and looking for the class name then.

You're better off trying to solve a specific problem and looking for the class name then.

This is why I open this thread.

Every time when I need to control anything that is outside Excel, I need to ask for the code.

So, I want to ask what can be written inside CreateObject().

And where I can find....

JP2112
08-19-2011, 10:13 AM
It sounds like at this point you don't have a specific problem you need to solve. When you do, try Google or ask on this forum. But nobody is going to spend their time compiling a list for you that probably isn't even possible anyway.