Running Excel macro that opened from web

S

Sam

Things to do:
What I need is to open an Excel file from a web site and run a macro
on that file by clicking a button.

Issue/problem:
Now I created an Excel file with a button to call a macro: PrintMacro.
It works fine. Then I have a web appliation using weblogic and struts.
It loads the Excel file from the file server and open the Excel file
with data and a button. So far so good. But when clicking the button,
it fails to trigger the macro. The Excel message said: The macro
''reportaction.do?file=20040625'!PrintMacro' cannot be found. If run
the macro from Tools/Macro, it works. Or if save the Excel file then
reopen it, the button does the work. That's to say: the macro itself
is OK but the button could find the right reference. I noticed that
the Excel file name was "YYYYMMDD" (eg. 20040625). After getting it
from the web app, its name seems to append to
'reportaction.do?file=20040625'. The 'reportaction' is an action class
the web app uses and the 'file=20040605' is a request that the user
selects.

Question:
I think it's because of its name change that makes the button lost its
reference. The button looks for '20040625'!PrintMacro, but not
'reportaction.do?file=20040625'!PrintMacro.
I don't know if this an Excel or java issue. I looked some Excel Q&A
sites and post questions there, but couldn't find any hint. It seems
they don't deal with Excel with java web issues.
So I come back to ask the java gurus: is it possible to get rid of the
appending part ('reportaction.do?file=)? Or some other way to open the
file and click the buuton to run the macro?

Code snippet for retrieving the Excel:
....
response.setContentType("application/vnd.ms-excel");
FileInputStream is = new FileInputStream(theFile);
ByteArrayOutputStream os = new ByteArrayOutputStream();
while ( is.available() > 0 ) {
os.write(is.read());
}
is.close();
os.writeTo(response.getOutputStream());
response.setHeader("Content-Disposition", "attachment; filename=" +
theFile + ".xls" + ";");
response.getOutputStream().flush();
response.getOutputStream().close();

Thanks
Sam
 
S

Sam

I got it fixed. I removed the parameter part from servlet by sending a
hidden value. So the browser opens the Excel without that
"?file=20040625". Then the button works.
It seems the Excel doesn't like "?" as its file name, I think.
Hope this may help those who might come into this problem.

Thanks anyway.
Sam
 
Joined
Nov 4, 2007
Messages
1
Reaction score
0
hey..I need your help.

i have written macros in excel 2003 and deploying in weblogic server 8.1 , using structs framework..

but i am getting error "error occurred initializing the VBA libraries" once i tries to open excel.

This works normally when i open the excel and runs. Problem is only after deploying..Please help me ..I am trying for this for last one week...

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top