Re: Word automation problem
Do you have the write access in that directory? If not then you won't be able to save a file. Also, make sure that the directory for "Save as" exists. Use proper exception handling techniques to get a proper error message. The error that you are getting does not reflect anything about the error..not meaningful at all. Also, make the line:
Code:
objWord2.ActiveDocument.SaveAs(FileName:="c:\mydoc\03020259-968.doc");
as
Code:
objWord2.ActiveDocument.SaveAs(FileName:=@"c:\mydoc\03020259-968.doc")
I am not sure if this works in VB.NET but that is how the paths are set in C# or else give one extra '/' at each location. Hope this helps. :thumb:
Re: Word automation problem
Thanks for the reply... but it's still the same... n btw...
objWord2.ActiveDocument.SaveAs(FileName:=@"c:\mydoc\03020259-968.doc");
the "@" is only applied for C#... in vb we don't need this. I got another info over the web saying that it has something to do with norton...
The way I c it... it has nothing to do with the code anymore.. it's just some external factor...
Anymore ideas?
Re: Word automation problem
Quote:
Originally Posted by newvisva
Thanks for the reply... but it's still the same... n btw...
objWord2.ActiveDocument.SaveAs(FileName:=@"c:\mydoc\03020259-968.doc"); the "@" is only applied for C#... in vb we don't need this. I got another info over the web saying that it has something to do with norton...
The way I c it... it has nothing to do with the code anymore.. it's just some external factor...Anymore ideas?
Ok...Fine..(I worked with C# and hence was not sure about VB.Net) But did you try putting up proper exception handling routines? What's the exception that you are getting? By the way, yes the antivirus running on systems also sometimes causes issues..it might be accessing some directory/files or something and then when you code tries to do so... you get an exception that the file being read blah blah is being used by some other process/application...Try disabling the antivirus stuff on the machine for a moment and check if it works...
Its hard to tell what might be causing this error without having to know the proper specific exception type that is being raised. :thumb:
Re: Word automation problem
Exterminator, Thanks for the reply...
I hv disable the realtime protection n still the same... I've also put an exception handler n still i get the same error msg. And then i found a few more pc with this prob... I think there must be other software inside it.
Any other idea?
Thanks
Re: Word automation problem
Instead of
objWord2.Documents.Open(Environment.CurrentDirectory & "\abc.doc")
'error occurs in the line below
objWord2.ActiveDocument.SaveAs(FileName:="c:\mydoc\03020259-968.doc")
try
dim wdoc as Word.document=objWord2.Documents.Open(Environment.CurrentDirectory & "\abc.doc")
wdoc.saveas(FileName:="c:\mydoc\03020259-968.doc")
It may be that the active document gets redefined in the server as different users access Word in the server - just a guess. Let me know if it helps.
Re: Word automation problem
Another thing you may try is instead of opening a server document and then saving it to the PC within Word, copy the document from server to PC first using 'File.Copy' from 'Systems.IO', and then open it in Word. Good luck.