Office automation for multiple versions, including 2007

M

Mark Booth

I have code that binds to the PIA for Word 2000 that I need to keep running.
One of my clients wants to upgrade to 2007 and I would like to make the same
code work for both. All of the kb articles I have read imply this should be
OK as long as I use the earlier references, but they only discuss the
versions from 97 to 2003. When I try to use the code with 2007 I get
IEHExceptions.

Am I missing some documentation? or can anyone advise me whether what I want
to do is possible (and give me a clues as to how to do it!)

Thanks
 
C

Cindy M.

Hi =?Utf-8?B?TWFyayBCb290aA==?=,
I have code that binds to the PIA for Word 2000 that I need to keep running.
One of my clients wants to upgrade to 2007 and I would like to make the same
code work for both. All of the kb articles I have read imply this should be
OK as long as I use the earlier references, but they only discuss the
versions from 97 to 2003. When I try to use the code with 2007 I get
IEHExceptions.

Am I missing some documentation? or can anyone advise me whether what I want
to do is possible (and give me a clues as to how to do it!)
Are you absolutely sure that what you're trying to do is still supported in
Word 2007? Have you tried building the project on the 2007 PIAs to see if it
works with those?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
M

Mark Booth

Hi, Cindy, thank you for replying and sorry for taking so long to respond.

I am not sure if I have the 2007 PIAs. I have not intentionally obtained
them and don't know if they came with the Office install? All I know is that
VS kindly offered to update my references when I opened my project after
installing Office 2007 and my code stopped working.

The articles that I had previously read suggested that if I wrote to the
lowest common denominator then it should continue to work on later versions.
This was up to 2003. There seem to be no articles on the subject later than
that. Oh! I have just gone back to check the article I was quoting from and
it has been changed to include 2007.

It now says:
"For example, if you have an existing Microsoft Visual Basic project that
was compiled on a computer with Microsoft Word 97, that project runs
correctly against Word 97, Word 2000, Word 2002, Microsoft Office Word 2003,
and Microsoft Office Word 2007. "
which is not the case. When I try to run it I get an SEHException.

Article 244167 seems to be incorrect.

Thank you again, for your help

Mark
 
C

Cindy M.

Hi =?Utf-8?B?TWFyayBCb290aA==?=,
I am not sure if I have the 2007 PIAs. I have not intentionally obtained
them and don't know if they came with the Office install?
If the .NET Framework is installed, Office installs the PIAs automatically.
All I know is that
VS kindly offered to update my references when I opened my project after
installing Office 2007 and my code stopped working.
So, if I've followed this correctly, the code stopped working both when
installing and running (without opening it in VS), and also after opening and
updating the references.
The articles that I had previously read suggested that if I wrote to the
lowest common denominator then it should continue to work on later versions.
This was up to 2003. There seem to be no articles on the subject later than
that. Oh! I have just gone back to check the article I was quoting from and
it has been changed to include 2007.
Yes, well that does assume you use commands that are backwards compatible. If
the way Word works has been changed, the code has to be changed. Over ten
years, things WILL change.
When I try to run it I get an SEHException.
You get any more information than that? Can you isolate the line of code? Which
language are you using?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
M

Mark Booth

Hi, again, Cindy, thank you for contuing to help clear my head

Cindy M. said:
If the .NET Framework is installed, Office installs the PIAs automatically.
That's good. I wasn't sure if the comment about updating references was the
same as installing the PIAs.
So, if I've followed this correctly, the code stopped working both when
installing and running (without opening it in VS), and also after opening and
updating the references.
Yes, you have a good grasp of the problem(s) - I don't think I made it clear
that I had two separate issues, so well done for deducing that!
Yes, well that does assume you use commands that are backwards compatible. If
the way Word works has been changed, the code has to be changed. Over ten
years, things WILL change.
I am sure that you are right, but it doesn't say so in the article. In fact
it implies quite strongly that the old code will still exist in the vtable -
I read something to this effect in another article. In trying to get back to
that article I found another that suggests that I am letting myself in for a
world of pain
You get any more information than that? Can you isolate the line of code? Which
language are you using?
Where I am going wrong seems to be trying to do this in C#. It looks like
the only safe way will be via VB, which I haven't used in over 7 years, and
then only for hobby purposes. Yes, I know this is the VBA discussion group,
but it is the one that is titled "Discussion in Office Developer Programming"
in Office Online.
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)

Sorry if this is coming via email - I am using Office Online and it doesn't
seem to give me any control over how this is sent.

All the best
Mark
 
C

Cindy M.

Hi Mark,
Sorry if this is coming via email - I am using Office Online and it doesn't
seem to give me any control over how this is sent.
No, you're OK in that respect :) I put this in my sig-line some ten years ago,
as people often figure they can get free email support said:
Where I am going wrong seems to be trying to do this in C#. It looks like
the only safe way will be via VB, which I haven't used in over 7 years, and
then only for hobby purposes. Yes, I know this is the VBA discussion group,
but it is the one that is titled "Discussion in Office Developer Programming"
in Office Online.
C#, yes... Most likely you're running into conflicting method signatures between
versions. You have a number of options. Off the top of my head

1. Since .NET Framework is JIT, you should be able to incorporate multiple
classes/dlls in your project. The main code can check the Office version, then
call into the correct code set for that version where methods have diverged over
the years.

2. Similar to the above: include a VB.NET "part" in your project that contains
calls to such methods. Remember, the .NET Framework compiles everything to MSIL,
irregardless of the language we humans use - you can mix-and-match :)

3. Use PInvoke (late binding) for methods with changed method signatures

IOW, no need to contemplate having to re-write your entire project in a
different language :)

As to the newsgroup you've been pointed to: try this interface for future dev
questions that need to be asked in newsgroups (rather than forums)

http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.office.dev
eloper.automation&lang=en&cr=US

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
M

Mark Booth

Cindy, you are wonderful, thank you for so clearly spelling out the options
(especially as I won't need to brush up my rusty old VB! - no offence to
those who love it, I am just getting old and set in my ways...)

Regards
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top