If one is developing a .NET application, how can I develop an application
that uses COM automation that targets multiple versions of Word? For
example, the signature for the Document.Open method is different from
version 9 to version 11 (and I'm sure there are other variations as well),
and I'm wondering if there's some easy way to deal with it.
At present I'm only concerned with supporting 9-11 (i.e. Word 2000, XP, and
2003), though I'd like to be flexible enough to deal with future versions as
well. How are developers dealing with this sticky situation now?
evan stone | software engineer
----------------------------------------
santa rosa, ca, usa 12 2985
Evan,
Unfortunately, there is no good solution for this. For something like
this, you will have to determine the version of Word you are using, and make
the appropriate call. This will also mean having references to the interop
assemblies for all three versions.
Given that the newer versions should support the older interfaces, you
might have some luck for most of the properties/methods, since you can
always downcast to the lowest version of the interface you will support.
However, if you need to do something different based on the version that
you have, you should probably write a utility class which will expose
methods which take the interface pointer, a version, and the parameters for
the operation, which will contain the separate logic.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Evan Stone" <re************ *********@hotma il.com> wrote in message
news:OS******** *****@tk2msftng p13.phx.gbl... If one is developing a .NET application, how can I develop an application that uses COM automation that targets multiple versions of Word? For example, the signature for the Document.Open method is different from version 9 to version 11 (and I'm sure there are other variations as well), and I'm wondering if there's some easy way to deal with it.
At present I'm only concerned with supporting 9-11 (i.e. Word 2000, XP, and 2003), though I'd like to be flexible enough to deal with future versions as well. How are developers dealing with this sticky situation now?
evan stone | software engineer ---------------------------------------- santa rosa, ca, usa
Office automation is pure evil.
--
Derek Davis dd******@gmail. com
"Evan Stone" <re************ *********@hotma il.com> wrote in message
news:OS******** *****@tk2msftng p13.phx.gbl... If one is developing a .NET application, how can I develop an application that uses COM automation that targets multiple versions of Word? For example, the signature for the Document.Open method is different from version 9 to version 11 (and I'm sure there are other variations as well), and I'm wondering if there's some easy way to deal with it.
At present I'm only concerned with supporting 9-11 (i.e. Word 2000, XP, and 2003), though I'd like to be flexible enough to deal with future versions as well. How are developers dealing with this sticky situation now?
evan stone | software engineer ---------------------------------------- santa rosa, ca, usa
> Unfortunately, there is no good solution for this.
It figures. For something like this, you will have to determine the version of Word you are using, and
make the appropriate call. This will also mean having references to the
interop assemblies for all three versions.
Is it possible to set references to multiple type libraries within one
assembly? How does that work - is VS.NET smart enough to create separate
namespaces for the different versions of the assemblies so we can
differentiate at runtime?
Or, would it make sense to create 3 (for now) assemblies that each have one
reference to each Word Interop assembly, and then use a Factory pattern to
instantiate the appropriate version of a wrapper object designed to handle
its corresponding version?
Then there's the matter of determining the version of Word that they have
installed, which is another problem to deal with as well (but probably less
tricky)....
evan stone | software engineer
----------------------------------------
santa rosa, ca, usa
Evan,
See inline: Is it possible to set references to multiple type libraries within one assembly? How does that work - is VS.NET smart enough to create separate namespaces for the different versions of the assemblies so we can differentiate at runtime?
No, it is not.
Or, would it make sense to create 3 (for now) assemblies that each have one reference to each Word Interop assembly, and then use a Factory pattern to instantiate the appropriate version of a wrapper object designed to handle its corresponding version?
Yes, it would. However, you would have to take care of the situations
where the interface differs. This would involve you having to create your
own interface, which in turn would check the version on those "tricky"
calls, and make the call to the appropriate interface. Then there's the matter of determining the version of Word that they have installed, which is another problem to deal with as well (but probably less tricky)....
I believe there is a registry setting which will tell you this.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m evan stone | software engineer ---------------------------------------- santa rosa, ca, usa
> Office automation is pure evil.
Agreed. But sometimes a necessary evil, unfortunately.. .
evan stone | software engineer
----------------------------------------
santa rosa, ca, usa
Inline. Is it possible to set references to multiple type libraries within one assembly? How does that work - is VS.NET smart enough to create separate namespaces for the different versions of the assemblies so we can differentiate at runtime?
No, it is not.
Neato!
....but it's also as I figured, so whatever. Or, would it make sense to create 3 (for now) assemblies that each have one reference to each Word Interop assembly, and then use a Factory pattern
to instantiate the appropriate version of a wrapper object designed to
handle its corresponding version?
Yes, it would. However, you would have to take care of the situations where the interface differs. This would involve you having to create your own interface, which in turn would check the version on those "tricky" calls, and make the call to the appropriate interface.
This is the scenario that I was originally planning for. I was planning on
writing an Adapter that would provide a *consistent* interface that the rest
of my application would interact with, and then pass the calls to the
appropriate underlying component. Then there's the matter of determining the version of Word that they
have installed, which is another problem to deal with as well (but probably less tricky)....
I believe there is a registry setting which will tell you this.
OK. I'll check this out... I'm sure it's fairly easy to do, and is not one
of my major concerns at this point.
Thanks for the information, Nicholas. You've been most helpful.
:)
evan stone | software engineer
----------------------------------------
santa rosa, ca, usa
Nicholas,
One more thing....
Do you have any idea as to how to get hold of the various .OLB type library
files one would need to accomplish what I'm hoping to do? Actually I *think*
I can get my hands on the v10 and v11 typelibs, but I'm not sure if I have
v9 around anywhere...
Thanks!
evan stone | software engineer
----------------------------------------
santa rosa, ca, usa
Evan,
If you have the original installs of those products, then you should be
able to get the type libraries.
Also, I forgot one thing. The recommendation that you use different
namespaces for the different versions can actually be done. Instead of
setting a reference in VS.NET to the COM object, use the TLBIMP utility to
generate the type libraries. That utility will allow you to specify the
namespace that the types in the assembly are in.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ca*******@caspe rshouse.com
"Evan Stone" <re************ *********@hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. .. Nicholas,
One more thing....
Do you have any idea as to how to get hold of the various .OLB type library files one would need to accomplish what I'm hoping to do? Actually I *think* I can get my hands on the v10 and v11 typelibs, but I'm not sure if I have v9 around anywhere...
Thanks!
evan stone | software engineer ---------------------------------------- santa rosa, ca, usa
Not if you choose the right tools, and C# is not such tool, programming
against Office is where VB.NET has got it over C# hands-down. For example
VB.NET supports late binding at the language level, no need to resort to
reflection, VB.NET supports optional parameters, named parameters and
passing expressions to ref. parameters, whereas C# does not.
Willy.
"carion1" <dd******@gmail .com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. Office automation is pure evil.
--
Derek Davis dd******@gmail. com
"Evan Stone" <re************ *********@hotma il.com> wrote in message news:OS******** *****@tk2msftng p13.phx.gbl... If one is developing a .NET application, how can I develop an application that uses COM automation that targets multiple versions of Word? For example, the signature for the Document.Open method is different from version 9 to version 11 (and I'm sure there are other variations as well), and I'm wondering if there's some easy way to deal with it.
At present I'm only concerned with supporting 9-11 (i.e. Word 2000, XP, and 2003), though I'd like to be flexible enough to deal with future versions as well. How are developers dealing with this sticky situation now?
evan stone | software engineer ---------------------------------------- santa rosa, ca, usa
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike MacSween |
last post by:
Office 2000
From Access I've been starting an instance of word and doing a mail merge.
Everything hunky-dory until I applied SP1 yesterday.
Now this:
dim wrd as Object
set wrd = CreateObject("Word.Application")
|
by: Neil Ginsberg |
last post by:
I have a strange situation with my Access 2000 database. I have code in the
database which has worked fine for years, and now all of a sudden doesn't
work fine on one or two of my client's machines. The code opens MS Word
through Automation and then opens a particular Word doc. It's still working
fine on most machines; but on one or two of them, the user is getting an
Automation Error. The code used is as follows:
Dim objWord As...
|
by: Cheval |
last post by:
Has anyone had any problems with inter-office automation between MS Word and
MS Access in Office 2003?
I have recently installed office 2003 in a new folder and have left the
older office 2000 and office XP components installed. ie I have
word/access/excel 2k/xp/2003 installed. I tried to do a usual access 2k to
word 2k automation yet I get the error "Automation Error" "ClassFactory
cannot supply requested class" when on late binding try...
|
by: Mystery Man |
last post by:
We are developing a C# application that has many interfaces to the
Microsoft suite (eg Word, Excel, Outlook, Powerpoint, etc). We need to
support Office 97, 2000, 2002 and any future versions.
Our first cut used early binding and worked fine with Office 2002. We
then ran on a machine that had Office 2000 installed and it all turned
to custard.
There appears to be a number of options to take to support multiple
versions:
|
by: Zoury |
last post by:
Hello!
I'm using the Microsoft Word 11.0 Object Library in my project. This means
the client must have Word 2003 on his computer to run my app properly.
What if I want my app to support multiple versions of Word? Would late
binding be an answer? If so, how do I handle little code differences between
each versions? As an example the ApplicationEvents3_Event_Quit event of the
ApplicationClass object of the Word 2002 Library has been...
| |
by: Mansi |
last post by:
I need to do some research on how to use excel automation from c#. Does
anyone know of any good books related to this subject?
Thanks.
Mansi
|
by: Marco Singer |
last post by:
Hi all,
I want to create an Office automation client for Office 97 (and newer) which
should automate Access, Excel and Word.
On my developer computer I have Office XP installed. In KB244167 (INFO:
Writing Automation Clients for Multiple Office Versions) Microsoft tells to
use the type libraries of the oldest office version the client should run
with.
So I copied the type library files from a Office 97 installed on another
|
by: Evan Stone |
last post by:
If one is developing a .NET application, how can I develop an application
that uses COM automation that targets multiple versions of Word? For
example, the signature for the Document.Open method is different from
version 9 to version 11 (and I'm sure there are other variations as well),
and I'm wondering if there's some easy way to deal with it.
At present I'm only concerned with supporting 9-11 (i.e. Word 2000, XP, and
2003), though I'd...
|
by: Chubbly Geezer |
last post by:
Hope you can help. I have created a mail merge word doc which seems to work
fine. When I close and reload it asks if I wish to pull in the data.
Great.
However, I want to print the results of the mail merge from within a VB.Net
app. I can create and load the word app/doc, but the document is not opened
as a mail merge doc. In fact the mail merge fields just appear as text.
Any ideas please, or alternative was to do this.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |