Results 1 to 6 of 6

Thread: Microsoft Excel Object Library question

  1. #1

    Thread Starter
    Hyperactive Member divined's Avatar
    Join Date
    Aug 2004
    Location
    Thessaloniki, Greece
    Posts
    447

    Microsoft Excel Object Library question

    Hello everybody

    I`d like to know if the Microsoft Excel 11 Object Library, installed by Microsoft Office 2003, can be used on machines which might have another version of Microsoft Office installed.
    SteadFast!

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Microsoft Excel Object Library question

    Moved from Classic VB forum.

    If your early binding by adding the reference then you will incur issues with different class interfaces between different versions.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Hyperactive Member divined's Avatar
    Join Date
    Aug 2004
    Location
    Thessaloniki, Greece
    Posts
    447

    Re: Microsoft Excel Object Library question

    so what can I do? How can I late bind to the Excel Object Library?
    SteadFast!

  4. #4
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Microsoft Excel Object Library question

    You can late bind Excel by declaring the variable as an object and using createobject. You must however be aware that some functions may not be available in older versions of Excel..

    Code:
      Dim objEX As Object
      Set objEX = CreateObject("Excel.Application")
    You will also not have the intellisense associated with the early binding method.
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  5. #5

    Thread Starter
    Hyperactive Member divined's Avatar
    Join Date
    Aug 2004
    Location
    Thessaloniki, Greece
    Posts
    447

    Re: Microsoft Excel Object Library question

    ok. It worked. But, I still haven`t understood the difference with the code I used :

    VB Code:
    1. Set oApp = New Excel.Application
    2.   Set oWB = oApp.Workbooks.Add
    3.   oWB.Sheets(1).Cells(1, 1).CopyFromRecordset rsTmpMhxanhma
    4.   oApp.Visible = True

    Am I not creating space for the oApp object at runtime as well? Does it have to do with the fact that oApp has already been defined as an Excel Application object. Finally do I also need to late bind the Excel.Workbook object as well?
    SteadFast!

  6. #6
    Lively Member JustinLabenne's Avatar
    Join Date
    Jul 2005
    Location
    Ohio
    Posts
    64

    Re: Microsoft Excel Object Library question

    This link may help you with your Early/Late knowledge.
    http://www.dicks-clicks.com/excel/ol...#Early_Binding

    Here is my method, while you are writing the application, set a reference to the appropriate library:

    Now delcare your variables:
    VB Code:
    1. DIm oApp as Excel.Application
    2. Set oApp = CreateObject("Excel.Application")

    Since the reference is set, oApp. will bring up the intellisense use. When you are done wrting the code and testing, and ready to distibute your project:

    Uncheck the reference and replace your Application specific variable types with Object:
    VB Code:
    1. DIm oApp as Object
    2. Set oApp = CreateObject("Excel.Application")

    Make sure you Compile to catch any errors with the code. When doing automation, you may need to use the applications constants in place of some things becasuse Late Binding can't take care of everything. It is more reliable of a method than early if you don't know what version's of office will be using you project and that the version's may switch.

    Hope this helps a bit.........
    Justin Labenne
    www.jlxl.net

Posting Permissions

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



Click Here to Expand Forum to Full Width