Home     Products      Support      Corporate     Sign In 

Support Knowledge Base, Article 1084

Product
ExcelWriter
Title
Running VBA macros in IE
Problem

Some VBA macros in a spreadsheet processed by ExcelWriter fail to execute when the file is opened in Internet Explorer. However, if the file is saved to the local filesystem and opened afterwards in Excel, the macro works fine. Is there a way to get the macro to work in the browser?

Solution

The answer is "no", but this issue relates to Excel and Internet Explorer, not ExcelWriter. ExcelWriter preserves all VBA macros when processing a spreadsheet. However, not all VBA will execute in the Excel browser plug-in. In order to guarantee that all your macros will run in your ExcelWriter-generated files, it is recommended to use the Save option that will open the spreadsheet in a separate Excel window rather than in the browser.

See this Microsoft Article: Some Macro Commands Are Not Run in MS Internet Explorer

Examples:

ExcelTemplate .NET

C#:

ExcelTemplate xlt = new ExcelTemplate();
xlt.Open("C:\\mytemplates\\WorkbookWithMacros.xls")
xlt.SetDataSource("DataSourceName",myDataSet);
xlt.Process();
//Save with the openInBrowser parameter to false
xlt.Save(Page.Response,"WorkbookWithMacros_out.xls",false)

ExcelApplication .NET

C#:

ExcelApplication xla = new ExcelApplication();
Workbook wb = xla.Open("C:\\myspreadsheets\\WorkbookWithMacros.xls")
//Rest of your code here...
//Save with the openInBrowser parameter to false
xla.Save(wb,Page.Response,"WorkbookWithMacros_out.xls",false)

ExcelTemplate COM

VBScript:
Set xlt = Server.CreateObject("SoftArtisans.ExcelTemplate")
xlt.Open "C:\myspreadsheets\WorkbookWithMacros.xls"
xlt.DataSource("DataSourceName") = myRecordset
' ExcelTemplate COM has no Save method, it does everything in .Process
' Set the ProcessMethod parameter to saProcessOpenInExcel
xlt.Process "WorkbookWithMacros_out.xls", saProcessOpenInExcel
ExcelApplication COM

VBScript:
Set xla = Server.CreateObject("SoftArtisans.ExcelApplication")
xla.Open "C:\myspreadsheets\WorkbookWithMacros.xls"
' Rest of your code here ...
' Save with ProcessMethod parameter set to saProcessOpenInExcel
xlt.Save "WorkbookWithMacros_out.xls", saProcessOpenInExcel, saFileFormatDefault

Related Articles:

This MS article discusses several other Excel features which do not work by default when a spreadsheet is opened in the browser. Workbook Settings Ignored or Disabled in MS Internet Explorer

Created : 7/30/2007 5:39:54 PM (last modified : 7/30/2007 5:39:54 PM)

Rate this article!

 
Comments



Copyright 2006 © SoftArtisans, Inc. All Rights Reserved.

Site Map     |     Privacy Policy     |     Contact Us