Consulting

Results 1 to 8 of 8

Thread: Set x = CreateObject()

  1. #1

    Set x = CreateObject()

    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

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    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.
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    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

  5. #5
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    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:

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

    Dim oExcel As Excel.Application
    Set oExcel = New Excel.Application
    [/VBA]

    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).
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by JP2112
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Quote Originally Posted by JP2112
    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....

  8. #8
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    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.
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •