473,396 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to run word macros from asp.net?

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...b;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
Nov 18 '05 #1
0 1104

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: MSNEWS | last post by:
Hi I'm using the word.applicationclass within my vb.net application to convert some word documents to text files. Is there anyway I can disable macros whilst loading the document, in Word I...
15
by: sparks | last post by:
They are wanting to use word to print out some cards 4 to a page preformatted stuff from an access database. the problem with this is they don't want to do the same card twice. How can setup a...
1
by: Simon | last post by:
How can I create a Macro in VB generated Word document. It would be nice to add a Button to to the Word Doc too...
1
by: djames | last post by:
Hi Gurus! Our users are required to use a MS Word template for reporting. The template has many bookmarked form fields. We have written an ASP.Net (2.0) application to populate those fields...
1
by: RobertK | last post by:
I need to write a c# code that will open up word documents and delete all the macros in it. Can some one please give me a code example or any ideas on how to do this. I already know how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.