Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Word Interop ,NET c#

Status
Not open for further replies.

kilgj001

Programmer
Apr 18, 2005
3
AU
I am having endless problems with getting a .net website to interact with the Word Interop Assembles, everything is setup, and all i am having trouble with at the moment is the Documents.Open() method.

the current error is
"System.Runtime.InteropServices.COMException (0x800A1499): The document name or path is not valid"
but the path is definately valid.

has anyone experienced this problem ? have any ideas ?

Greg

im calling the library like this;

using System.Runtime.InteropServices;
using Word = Microsoft.Office.Interop.Word;

and the function that calls it is like this;

public string openFile(string filename){
try{

object fileName = " object readOnly = false;
object isVisible = true;
object missingValue = Type.Missing;

this.doc = this.word1.Documents.Open(ref fileName, ref missingValue, ref missingValue, ref isVisible, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue,ref missingValue);


this.doc.Activate();
return("true");
}catch(Exception e){
return(e.ToString());
}
}
 
I am using a little different approach.Here is the code:

Code:
	object myFalse = false;
	object myTrue = true; 
	object missingValue = Type.Missing;
	string workname = @"C:\Inetpub\[URL unfurl="true"]wwwroot\....\Doc.doc";[/URL]
	Word.ApplicationClass wApp2 = new Word.ApplicationClass();

			// open document
	object objFileName = workname;
	wApp2.Documents.Open(ref objFileName,ref missingValue,
		ref myFalse, ref missingValue, ref missingValue, 
		ref missingValue, ref missingValue, ref missingValue,
		ref missingValue, ref missingValue, ref missingValue,
		ref myTrue, ref missingValue, ref missingValue,
		ref missingValue, ref missingValue);
	// replace known fields
			
			 		
	//save
			 
	wApp2.Documents.Save(ref myTrue,ref missingValue);

	// close and quit		 
			 
			 
	wApp2.Documents.Close(ref myFalse,ref missingValue,ref missingValue);
	wApp2.Quit(ref myFalse,ref missingValue,ref missingValue);
This is the working code. I am using Microsoft Word 11.0 Object and works fine so far on ASP.NET web application.

Hope this will be helpfull to you.
Spent
 
You know that Word is not suitable for use in a server environment? It's not reentrant.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top