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!
Answers (2)
2
Hi,<br><br>
Do you need to validate a row or column?<br>
You can convert to int as below-<br>
Convert.ToInt32(dt.Rows[0]["colname"].ToString())>0
Accepted 1
use the string conversion code. the code is as follows
consider it as follows.
int a;
a=Console.ReadLine(int.Parse());
1
1
hi raja,
This is what you were looknig for?
foreach(DataRow dr in dt.Rows)
{
if(Convert.ToInt32(dr["colname"])>0)
{
//do something
}
}
1
http://stackoverflow.com/questions/1019793/how-can-i-convert-string-to-int
1
Hello Raja thank you for writing below links helpful for your question...........:)
and please clear your question first.....if you not looking that
https://msdn.microsoft.com/en-IN/library/bb397679.aspx
http://stackoverflow.com/questions/1019793/how-can-i-convert-string-to-int
http://sqlserverplanet.com/tsql/convert-text-string-to-numbers-int