2
Answers

Store Macro through C#

chenthil vela

chenthil vela

14y
3k
1
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)
0
Nilesh Shah

Nilesh Shah

NA 22.3k 214.8k 7y

If not using server on session, then you can use cookies on client side

but I fail to understand why you don't want to use session? it helps in managing user requests in betterway. what you want to achieve by not using session? 

Accepted
2
Nilesh Shah

Nilesh Shah

NA 22.3k 214.8k 7y

if you have memory issues, then instead of storing session in-proc (in memory),you can store the session in database server. this way ur memory will not be occupied by session

if at all you dont want to use session, then you can maintain user data using cookies or using query string

1
Nilesh Shah

Nilesh Shah

NA 22.3k 214.8k 7y

1000 concerent users is nothing, even the sites with millions of concerent users implement sessions

it depends on what resources you have

are you going to host by your own? or on cloud?
 
it will be better if you provide all the info. together while posting question, instead of writing bits and pieces in different replies 
-1
Pradeep Yadav

Pradeep Yadav

NA 1.8k 150.6k 7y
You think it as 1000 concerent users.
 Then.......?
-1
Pradeep Yadav

Pradeep Yadav

NA 1.8k 150.6k 7y
Huge user , memory issue
 
However cookies are not safe.