TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
chenthil vela
NA
1
0
Store Macro through C#
Aug 5 2010 8:43 AM
I wanted to write a macro and run it from C#. The
following is the code.
Microsoft.Vbe.Interop.VBProject vbp = new Microsoft.Vbe.Interop.VBProject();
Microsoft.Vbe.Interop.VBComponent vbc = vbp.VBComponents.Add(Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ct_StdModule);
StringBuilder sb = new StringBuilder();
sb.Append("Sub FormatSheet()" + "\n");
sb.Append(" Selection.Find.Text= 'A-Gen'" + "\n");
sb.Append(" Selection.Find.Execute(ref fndtext, 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)" + "\n");
sb.Append(" Selection.Range.Paragraphs.OutlineLevel = Microsoft.Office.Interop.Word.WdOutlineLevel.wdOutlineLevel1");
sb.Append("End Sub");
string sCode = sb.ToString();
vbc.CodeModule.AddFromString(sCode);
But it shows the error as
{"Retrieving the COM class factory for component with CLSID {0002E169-0000-0000-C000-000000000046} failed due to the following error: 80040154."}
Thanks in advance for any help!
Reply
Answers (
2
)
Errors when Report is generated in C# with setup file
How to avoid version changes