vb.net - How do I run an Excel Macro from a .Net web system? -


i'm trying run excel macro called sheet1.workbook_open .net web system.

below current code.

xlapp = new excel.application xlworkbook = xlapp.workbooks.open("c:\testing\tempfile.xlsm") xlworksheet = xlworkbook.worksheets("testspreadsheet")  dim macroname string = "sheet1.workbook_open"  xlapp.run(macroname)  dim filedate string = sysdatetextbox.text filedate = filedate.replace(" ", "") filedate = filedate.replace("/", "") filedate = filedate.replace(":", "")  filename = "c:\testing\file" & filedate & ".xlsm"  xlworkbook.saveas(filename) xlworkbook.close(true) xlapp.quit() 

however, fails on line xlapp.run(macroname) error;

exception hresult: 0x800a01a8   system.runtime.interopservices.comexception: exception hresult: 0x800a01a8 

why happening, , how can fix it? error doesn't happen when project hosted on local machine - when on server.

i'm afraid that's not answer you'd hear, correct answer is... you don't.

microsoft explicitly states office automation not supported unattended code, includes web applications:

microsoft not recommend, , not support, automation of microsoft office applications unattended, non-interactive client application or component (including asp, asp.net, dcom, , nt services), because office may exhibit unstable behavior and/or deadlock when office run in environment.

if need interact excel files, correct solution use .net library supports excel file format. unfortunately, means won't able use existing legacy excel vba code.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -