|
-
August 3rd, 2005, 03:58 AM
#1
Word automation problem
I hve a problem... i get this error called "The server threw an exception"
I installed my program in a client pc with the following code:
Dim objWord2 As Object
objWord2 = CreateObject("Word.Application")
objWord2.Visible = True
objWord2.Documents.Open(Environment.CurrentDirectory & "\abc.doc")
'error occurs in the line below
objWord2.ActiveDocument.SaveAs(FileName:="c:\mydoc\03020259-968.doc")
It works in other pc except for one. That pc is running winxp sp2 n office xp.
I reinstall office n still the same 
It there another code to save a document?
Thanks in advance
Back after a long hibernation.
-
August 4th, 2005, 09:12 AM
#2
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.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
August 4th, 2005, 08:56 PM
#3
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?
Back after a long hibernation.
-
August 5th, 2005, 02:45 PM
#4
Re: Word automation problem
 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.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
August 9th, 2005, 10:12 PM
#5
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
Back after a long hibernation.
-
August 10th, 2005, 07:22 AM
#6
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.
-
August 10th, 2005, 07:25 AM
#7
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|