Reply
 
Thread Tools Display Modes
  #1   Report Post  
koala
 
Posts: n/a
Default Problem Saving using Visual C#.NET

Hi,
I'm trying to save a document from a web click as described in the
knowledge base article.

http://support.microsoft.com/kb/316384/EN_US

Instead of using Windows Application I use web application asp button to do
the work. I'm trying to save the document. However, both save and saveAs
doesn't not work for some reason. Here is the code for save:

object fileName = "c:\\MyNewDocument.doc";
oWord.Documents.get_Item(ref fileName).Save();

It gives me this error:System.Runtime.InteropServices.COMException: Bad file
name

When I try to use saveAs as follow:

oDoc.SaveAs(ref fileName, ref missingValue,ref missingValue, ref
missingValue, ref missingValue,ref missingValue, ref missingValue, ref
missingValue,
ref missingValue, ref missingValue, ref missingValue,ref missingValue, ref
missingValue, ref missingValue,ref missingValue, ref missingValue);

It hangs forever and does not go through.

Thanks for the help in advance

Koala
  #2   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

Hi ?B?a29hbGE=?=,

Note that you've posted in an end-user group, and the chances of getting a
reply to a C# question are vanishingly remote. You should be posting in an
office.developer newsgroup. But see below...

Instead of using Windows Application I use web application asp button to do
the work. I'm trying to save the document. However, both save and saveAs
doesn't not work for some reason. Here is the code for save:

object fileName = "c:\\MyNewDocument.doc";
oWord.Documents.get_Item(ref fileName).Save();

It gives me this error:System.Runtime.InteropServices.COMException: Bad file
name

I'm a bit vague with this in C#; I know that sometimes you need to specify
double backslashes in order to get a single one in the result; other times not.
Do you have any way of testing whether what's getting passed through ref
fileName contains single or double backslashes? Word will accept only one...

And, generally, you'd refer to an open document with only the file name (and
not the full path). You might want to see if Word accepts that.

You might also see if oWord.Documents[1].Save will work - just to test whether
save is working at all.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :-)

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual basic runtime error 5216, there is a printer error pat@stlukeshospital Microsoft Word Help 2 June 6th 18 08:53 PM


All times are GMT +1. The time now is 08:51 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"