Interop Word problem+ASP.NET page

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, i'm in desperate need of help to fix a problem that i have, the problem
is the following:
I have an ASP.NET aplication that to open an word template document, this
aplication is in C#(using .NET 1.1 and VS2003), i have register the office
interop DLL in the GAC an have also install the office program in the
machine, this is in a virtual machine that i use to make the development, on
the host machine i have the same interop DLL's and the office suite install,
use the .NET 2.0 and the VS2005 to create a test aplication that opens the
same template this code works fine, but the on in the virtual machine gives
me an error on this line " Document wordDoc = wordapp.Documents.Open(ref
testedoc,ref missing,ref missing,ref missing,ref missing,ref missing,ref
missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref
missing,ref missing,ref missing);" it says "The command is not available", i
don't know what the problem might be, but need to solve this problem ot
finish the project. Thanks in advance for any help provided, surely
appreciate it.

ApplicationClass wordapp = new ApplicationClass();
object missing = Missing.Value;
object testedoc = @"E:\My Documents\Visual Studio
2005\WebSites\webword\Politica-Plano.dot";
object documento = @"E:\My Documents\Visual Studio
2005\WebSites\webword\teste.doc";
Document wordDoc = wordapp.Documents.Open(ref testedoc,ref
missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref
missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref
missing,ref missing);
wordDoc.Activate();
wordapp.Selection.TypeText("ola isto é um teste");
wordapp.Selection.TypeParagraph();
ReplaceBookmark(wordDoc,"nomedocumento","Testando o documento com
bookmarks");
wordDoc.SaveAs(ref documento,ref missing,ref missing,ref missing,ref
missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref
missing,ref missing,ref missing,ref missing,ref missing,ref missing);
wordapp.Quit(ref missing,ref missing,ref missing);
Response.Clear();
Response.ContentType = "application/doc";
Response.AddHeader("Content-Disposition",
"attachment;filename=testedoc.doc;");
Response.WriteFile(documento.ToString());
 
Maybe you have other version in the virtual machine, At www.microsoft.com
you can download the PIA (primary interop assemblies) to use interop on ms
office.

regards
daniel
 
Hey this is very funny i'm having the same problem.

Exactly like yours i'm trying to open Word on Virtual PC. I'm using
Asp.net 2.0 ( vb.net)
This was working fine yesterday and all of a sudden is not working. It
tells me "This command is not available" I know very well is not my
code cause it was working fine yesterday...Ooh one other thing my MS
Office is not activated. So i am going to activate this and see where
this takes me
 
Back
Top