Is there any way of running and compiling with known errors in the code.

Her is my reason. I am using a reference to word 2008 and word 2010, so as the program will work with both versions. Trouble is that if the computer I am using to test the code, only has one installed (naturally) so the program wont compile or run for me to test other parts of the program. There must be a way of ignoring error which wont make any difference to the run time compile program.

Is there any way of running and compiling with known errors in the code.

Compiling? yes, running? No because the program has to be error-free in order to execute the code. There is no point in trying to execute a program that contains compile-time errors. How do you expect the compiler to generate executable code when the source code is crap?

Do you really need references to both versions of word at the same time? If you have the reference to word 2010 just test your program on a computer that has word 2008 installed on it.

Not as easy as that, and it is not CRAP code it is CRAP software that doesn't allow for this to work. On VB6 it would have worked fine.
The reason for the errors is because word 2003 needs to have the declared
Imports Word = Microsoft.Office.Interop.Word to work, but 2007 onwards uses a completely different method and doesn;t recognise this statement, and thus the several hundred of statement that uses the "word" variable. The fact is that the compiled programme would never error because the code would route the programme to the correct version installed.

And I cant test on a computer that has 2010 on it as that will then error on the 2003 part of the code. nAnd in any case it is not so much as testing the programme as adding new code to other parts of the programme. I am at a loos as to what to do.

The only method I see available to me is to have a different database programme for each version of work, which seems ridiculous. But it looks like that is the way it has to be, or go back to VB6!

Couldn't you check the version and then conditionally branch from there? I found an example here: Click Here. Some sample code to look at might be helpful... By the way, what versions are you trying to support? The original post states Word 2008 and Word 2010, but Word 2008 is in Office 2008 for Mac only as far as I know.

The Microsoft.Office.Interop.Word namespace is documented on MSDN for Word 2003 and Word 2010 only, so apparently not distributed with any other versions of Office. That said, the Interop assemblies are available for redistribution. The assemblies for Office 2010 are found here: Click Here, I have no idea what will happen if you install and reference those assemblies on a system that has Word 2007 installed, and whatever code you write would have to be isolated by version and tested on a specific basis.

HKLM\Word.Application.CurVer also has the version number on my system (Office 2010), but I don't know whether that key exists in any/all other versions.

Again, it would be helpful to know what versions you need to support.

Yes, Interesting reading, and it uses VB6, which seems to work fine without the errors. I am trying to use all versions of word, ie 2000,2002,2003,2007 and 2010. But as 2000 and 2002 are too different I have decided to drop them.

I have now managed to convert the errors to warnings by somehow adding the references even though the computer doesn;t have the relevant versions installed, and it seems to work, I will know for sure when I try running the compiled programme on some other machines that only have one version installed, but I think it is going to work.

If you're all set, mark the thread as solved.
Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.