Button fails to call macro when open an Excel file from web

S

Sam

I have an Excel file with a button to run a macro: select sheets and
print preview. It works when the file is opened with Excel. The macro
is simple:
Sub PrintMacro()
Sheets(Array("tables", "data", "charts")).Select
Sheets("tables").Activate
ActiveWindow.SelectedSheets.PrintPreview
End Sub

I need to open it from web. When user selects the file, the web app
retrieves the file and responses to open an Excel file. So I built a
web app using Weblogic and Struts. After user clicks the link to the
file, an Excel file was loaded from the server with chart, data, and a
button to trigger the macro. The title bar shows: Microsoft Excel -
http://myhostname:myportnumber/mywebapp/reportaction.do?file=20040624
[Group] [Read only]. It works so far.

But when click the button, an Excel message box appears: The macro
''reportaction.do?file=20040624'!PrintMacro' cannot be found.
If look into Tools/Marco, PrintMacro can be found in 3 "Macros in"
status: 1. All Open Workbooks, 2. This Workbook, and 3.
reportaction.do?file=20040624. Click Run in Macro window, it runs in 3
status. Or if the file saved and reopend, click the button and it
works.

Could anyone know why is it and the way to solve the problem?

Thanks so much!
Sam
 
S

Sam

I got it fixed. I've managed to remove the part after "?" in my
servlet request and the browser shows like
"http://myhostname:myportnumber/mywebapp/reportaction.do". Then the
button works.
It seems the Excel doesn't like "?" in its file name, I guess.

This question was posted for 6 days and nobody seems interestd in it.
Maybe it's not funny enough.

Hope it may give a hint to those who encounter the similar issue.

Thanks
Sam
 

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

Top