How to run word macros from asp.net?

J

John Dolinka

I am trying to run a word macro via automation from an asp.net application.
The document loads well enough, but I get an "Unable to run the specified
macro" error when attempting to run the macro. I am using authentication
"no anonymous", so it should be able to get the right Normal.dot from my
profile (correct assumption?). I am aware of article
http://support.microsoft.com/default.aspx?scid=kb;EN-US;288366 but that
does not really work (using Word 2003 and reg key only is only good to
2002).

Additonal information.
The exception returns -532459699 for the _COMPlusExceptionCode
And the "help url" is @"C:\Program Files\Microsoft
Office\OFFICE11\1033\wdmain11.chm#37401" which is unhelpful since url is
bogus.

Snippet
object readOnly = false;
object isVisible = true;
Word.Document oWordDoc=null;
Word.ApplicationClass oWordApp=null;
object missingValue = Type.Missing;
try{
oWordApp = new Word.ApplicationClass();
}
catch(Exception exc){
ExceptionManager.Publish(exc);
}

try{
oWordDoc = oWordApp.Documents.Open(ref fileName, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref isVisible, ref missingValue, ref missingValue,
ref missingValue, ref missingValue);
}
catch(Exception exc){
ExceptionManager.Publish(exc);
}


oWordDoc.Activate();

oWordApp.Selection.TypeText("This is the text");
oWordApp.Selection.TypeParagraph();
oWordDoc.Save();
try{
string go="NewMacros.HelloWorld";
---failes after executing next line-----
oWordApp.Run(go,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,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);
}
catch(Exception exc){
ExceptionManager.Publish(exc);
}

Thanks,

John Dolinka
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top