Results 1 to 14 of 14

Thread: Word automation and backwards compatability

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Word automation and backwards compatability

    I have a Windows application which opens a document in Word 2003.
    Its fairly straight forward and works well enough.

    The problem is that I have to make this compatable with Office 2003, XP and 2007.

    How do you guys go about this. I have access to all these versions here at the office but have no idea how to implement this. I take it I have to look into late binding.

    Any tips are most welcome.

    Thanks In Advance
    Last edited by venerable bede; Jul 8th, 2008 at 04:39 AM.

    Parksie

  2. #2
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: Word automation and backwards compatability

    Firt of all use late binding (Search on it)
    Second use Office XP as your testcase(most stuff is backward compatible)

    Good Luck,
    because 2007 has large object changes

    I do have a sourcecode to read the installed versions of Word out of the register somewhere, but that's in VB6.0 so I doubt it would be helpfull
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

  3. #3

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Re: Word automation and backwards compatability

    Thanks

    I am looking at late binding now but I'll admit to being confused.

    Parksie

  4. #4
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Word automation and backwards compatability

    Quote Originally Posted by venerable bede
    I have a Windows application which opens a document in Word 2003.
    Its fairly straight forward and works well enough.

    The problem is that I have to make this compatable with Office 2003, XP and 2007.

    How do you guys go about this. I have access to all these versions here at the office but have no idea how to implement this. I take it I have to look into late binding.

    Any tips are most welcome.

    Thanks In Advance
    Hi,

    If you're concernd with supporting Office 2003 and Office 2007, then change your reference from version 12. That should fix it.

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  5. #5
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Word automation and backwards compatability

    What will that fix? Surely that wont help if the objects and classes etc in the Office 2007 PIAs arent all identical to the Office 2003 and Office XP ones... which I doubt they are.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  6. #6
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: Word automation and backwards compatability

    No,

    In the end you do not want to have any reference at all.

    For Developing sake reference the lowest version and use interop like:
    The Microsoft Word 10.0 Object Library dll in the Com Tab

    The you can write stuff like:
    Code:
    Dim WordApp As  Microsoft.Office.Interop.Word.Application
    Dim WordDoc As New Microsoft.Office.Interop.Word.Document 
    
    WordApp = new Microsoft.Office.Interop.Word.Application
    WordDoc = WordApp.Documents.Open(path_to_file_here)
    After Writing al you need to do change all Variables to Objects and Use CreateObject Like

    Code:
    Dim WordApp As Object
    Dim WordDoc As  Object
    Obj = CreateObject("Word.Application")
    WordDoc = WordApp.Documents.Open(path_to_file_here)
    And Don't Forget to remove the reference to "Microsoft Word 10.0 Object Library "
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

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

    Re: Word automation and backwards compatability

    For those 3 versions you would have more trouble writting separate code to handle 2007 as its defaults are different from 2002/2003.
    Use Late Binding and check the version before proceeding farther in your code so if they are using Word 97/2000 you can handle it as you desire by either notifying them or by kicking them out and requesting the proper version.

    VB6/Office Automation (also Late Binding):
    http://www.vbforums.com/showthread.php?t=406640

    Determine version:
    http://www.vbforums.com/showthread.php?t=402020

    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

  8. #8
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Word automation and backwards compatability

    Quote Originally Posted by Dnereb
    No,

    In the end you do not want to have any reference at all.
    I dont get it, I thought you had to have those references in for that code to work? If thats not the case, then why does the IDE not even let you compile if the reference isnt there?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


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

    Re: Word automation and backwards compatability

    I think he means no references to Office/Word
    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

  10. #10
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Word automation and backwards compatability

    Ohh right, so he doesnt mean references as in project references - just literally refering to specific versions of Word/Office?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


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

    Re: Word automation and backwards compatability

    Just project references to Word/Office. When you Late Bind you dont use any references to the library that you are using. In this case its Word but when you add a reference to Word, a reference to Office is also added because Word is dependant upon the base Office libraries.
    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

  12. #12
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Word automation and backwards compatability

    Ah i see, I think I need to do some reading up on Late Binding then, sounds interesting/useful
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


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

    Re: Word automation and backwards compatability

    Check out my FAQ item on Late Binding in VB.NET for more and some code examples.
    http://www.vbforums.com/showthread.php?t=406637
    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

  14. #14
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: Word automation and backwards compatability

    Yes I just meant the reference I mentioned in the post.
    The key to achieve this is this line:
    Obj = CreateObject("Word.Application")
    This way you can creat an object that isn't referenced.
    You need to use a try catch block to catch errors if office/Word isn't installed and probably You'll need to use try catch as well if you have to use 2007 specific features and write XP/2003 alternatives.

    Tip: Write some code in Word VBA and use it's objectbrowser if you want to figure out how to Word object is used, it's a bit of a monster designwise.
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

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