I want to support all Office suites in one application using Office Interop.
I was able to do this in Visual Basic by making use of CreateObject()?
The problem was that I wasn’t able to see the functions up-front and had to jump around between docs to get it done (Due to Object being used).
If I use a factory pattern and have an implementation for each version of Office, would it work?
Example:
Factory->ABaseOffice GetImplementation(string office_version)
Returns an instance of ABaseOffice which is implemented by Office2000 and OfficeXP.
This way if a new Office version comes out I just have to write the speciffic code for it and not be bothered about the previous versions or depending on 3rd party software.
I don’t want to follow the COM/Interop – Supporting Multiple Versions route.
yes – in theory this works… the problem is that you definitely can’t reference different versions of the Interop-DLLs in the same project… so you will still have to use the late binding approach for the implementations of the
ABaseOfficeinterfaceUPDATE – as per comments:
In theory the described option (see http://blogs.msdn.com/b/ansonh/archive/2006/09/27/774692.aspx) would allow for adding those references… several reasons not to do so: