By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,281 Members | 2,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,281 IT Pros & Developers. It's quick & easy.

Interop Word problem+ASP.NET page

P: n/a
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());
Sep 5 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

"Hospital S.Sebastiao" <Hospital S.*********@discussions.microsoft.com>
wrote in message news:7F**********************************@microsof t.com...
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());

Sep 6 '06 #2

P: n/a
They are the same, as is the office version

"daniel #" wrote:
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

"Hospital S.Sebastiao" <Hospital S.*********@discussions.microsoft.com>
wrote in message news:7F**********************************@microsof t.com...
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());


Sep 6 '06 #3

P: n/a
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

Sep 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.