|
-
Jul 8th, 2008, 04:24 AM
#1
Thread Starter
Fanatic Member
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.
-
Jul 8th, 2008, 04:39 AM
#2
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.
-
Jul 8th, 2008, 04:51 AM
#3
Thread Starter
Fanatic Member
Re: Word automation and backwards compatability
Thanks
I am looking at late binding now but I'll admit to being confused.
-
Jul 8th, 2008, 05:01 AM
#4
Re: Word automation and backwards compatability
 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
-
Jul 8th, 2008, 06:46 AM
#5
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.
-
Jul 8th, 2008, 11:13 AM
#6
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.
-
Jul 8th, 2008, 12:34 PM
#7
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jul 8th, 2008, 01:31 PM
#8
Re: Word automation and backwards compatability
 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?
-
Jul 8th, 2008, 01:36 PM
#9
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jul 8th, 2008, 05:38 PM
#10
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?
-
Jul 8th, 2008, 07:54 PM
#11
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jul 8th, 2008, 07:56 PM
#12
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
-
Jul 8th, 2008, 07:58 PM
#13
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jul 9th, 2008, 01:25 AM
#14
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|