Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Automating MS Office97/2000/XP with same C# Code

Automating MS Office97/2000/XP with same C# Code

Scheduled Pinned Locked Moved C#
csharpwpfwcftutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi, Can any one tell me how I can Automate MS Office 97/2000/XP using the same C# Code. Using VB I could use Late Binding to do this, but I can not figure out how to do it using C#. I wish to have one C# Program which will work on all versions of MS Office. Thanks for your time Peter Tewkesbury Peter Tewkesbury

    J 1 Reply Last reply
    0
    • L Lost User

      Hi, Can any one tell me how I can Automate MS Office 97/2000/XP using the same C# Code. Using VB I could use Late Binding to do this, but I can not figure out how to do it using C#. I wish to have one C# Program which will work on all versions of MS Office. Thanks for your time Peter Tewkesbury Peter Tewkesbury

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      Just off the top of my head, so i have no idea how much work this would be... Abstract the functionality you need from office into an interface or abstract class. Then write a class for each version of office. At runtime detect which version of office is installed and use the proper class. You might have to break each class into a separate assembly so it won't try loading office 97 typelib info when you want xp info. My knowledge of how the references get loaded is minimal though, so this may be an extraneous step. Hope this at least gives you some ideas, James Sonork ID: 100.11138 - Hasaki

      P 1 Reply Last reply
      0
      • J James T Johnson

        Just off the top of my head, so i have no idea how much work this would be... Abstract the functionality you need from office into an interface or abstract class. Then write a class for each version of office. At runtime detect which version of office is installed and use the proper class. You might have to break each class into a separate assembly so it won't try loading office 97 typelib info when you want xp info. My knowledge of how the references get loaded is minimal though, so this may be an extraneous step. Hope this at least gives you some ideas, James Sonork ID: 100.11138 - Hasaki

        P Offline
        P Offline
        Peter Tewkesbury
        wrote on last edited by
        #3

        Thanks for the info. I now have a working solution thanks to .NET 1. Write the base class in C# in a seperate DLL & namespace 2. Derive a new class in VB from the base class in another DLL - I can use Late Binding features of VB to automate MS Office (All Versions) without writing pages of code. 3. Use this new class in the top level program (C#) All Thanks for .NET Man I love .NET :) :) :) :) :) :) :) Peter Tewkesbury Developer ibsl technologies

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups