and this is what i get
I base my explanation on Java: Probably NullReferenceException is the same as a NullPointerException. This means that or objword is Nothing, or ActiveDocument is Nothing
A very important thing to know is what the last thing was that has been executed, before the exception is thrown. Since you didn't put your entire code inhere and I don't know enough about VB.net, I can only guess... What happens when objword = CreateObject("notepad.Application") fails? What happens when objword.Documents.Open("...") fails?
There's a really good chance that one of those things fail.
My guess: CreateObject fails and keeps objword = Nothing.
Then you call a field within objword: you get objword.Documents and perform .Open on that. But since objword = Nothing, there is no .Documents to call, so this will generate an NullReferenceException.
You catch that, that's ok, but what do you do then? You call objword.ActiveDocument.Close(), AGAIN ON THE NOTHING OBJECT
since objword is still Nothing, .ActiveDocument can't be read out, and this will generate a NullReferenceException AGAIN. Since you don't catch that, the exception is thrown to the system and the system will show you the "crash" because basically that's what your "program" does at that point.Suggestion
Check on every value that could be Nothing:
objword = CreateObject("notepad.Application")
If objword is Nothing then
MessageBox("Could not create notepad.Application");
' at this point, you can be sure that objword is not Nothing,
' otherwise the program would be shut down.
You should do things like that on every object that could be possibly Nothing.
Oh and don't copy-paste my code snip, because it's probably no good VB. As I said: I don't know the exact syntax of VB.net, but you get the point. If you don't, consider a programming course first EDIT:
Perhaps it helps too if you comment in English, especially when you ask for help. Not everyone can speak Spanish - I'm one of them!