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)
1
Try this:
foreach (var item in storeItem)
{
<input type="button" id="btn" value="@item.StoreItemName" onclick="addvalue($(this))" />
}
<script>
function addvalue(e) {
$('#ItemName').val(e.val())
}
</script>
0
Hi,
Please try like below -
<input type="button" id="btn" value="@item.StoreItemName" onclick="addvalue(this.value)" />
script -
function addvalue(myval) {
$('#ItemName').val(myval);
}
The error in your question is not from the script you provided. It was coming from some other script.
0
@if (TempData["srResult"] != null)
{
List<StoreItem> storeItem = (List<StoreItem>)TempData["srResult"];
foreach (var item in storeItem)
{
<input type="button" id="btn" value="@item.StoreItemName" onclick="addvalue()" />
}
}
0
Hi,
Please post you whole Jquery code as error is with "toLowerCase" method and that code snippet is not present in this screenshot.
Please refer
https://stackoverflow.com/questions/23723005/uncaught-typeerror-cannot-read-property-tolowercase-of-undefined
https://teamtreehouse.com/community/uncaught-typeerror-cannot-read-property-tolowercase-of-undefined