Want to share a script? Click here to contribute!
Author: Tim Ackermann
Platform: Windows NT, Windows 2000, Windows XP
Use this small snippet of VBScript to automatically open a spreadsheet into Excel from Internet Explorer, instead of having it open directly in Internet Explorer. I've been reading online about scripting for a while. Recently I had a client request a simple thing from me.
Problem: Figure out a way to open an Excel spreadsheet in Microsoft Excel from a Web page instead of it opening in Internet Explorer.
After about two hours of searching, I found something at Microsoft that showed me how to complete this with VBScript.
Download the script.
Scroll down to view the script.
How to open a spreadsheet into Excel from Internet Explorer.
============================================================ I'm including two files with this readme: Excel_Test.htm and test.xls Excel Test.htm is a working test webpage. Copy test.xls to c:\temp Double-click on Excel_Test.htm ============================================================ Adapted from Microsoft Knowledge Base Article: http://support.microsoft.com/support/kb/articles/Q178/2/22.ASP ============================================================ 1. Add the following to the webpage in the <HEAD></HEAD> section: <SCRIPT LANGUAGE=VBScript> Dim objExcel Sub Btn1_onclick() call OpenWorkbook("http://www.microsoft.com/subdirectory/test.xls") End Sub Sub OpenWorkbook(strLocation) Set objExcel = CreateObject("Excel.Application") objExcel.Visible = true objExcel.Workbooks.Open strLocation objExcel.UserControl = true End Sub </SCRIPT> ============================================================ 2. Then add the following to the webpage in the <BODY></BODY> section: <INPUT TYPE=BUTTON NAME=Btn1 VALUE="Open Excel File"> ============================================================ 3. Insert the correct path to the Excel file. ============================================================ NOTE: You don't have to use a url in the above example: Ex: OpenWorkbook("\\server\share\folder\file.xls") Ex: OpenWorkbook("g:\folder\file.xls") NOTE2: You can change "Open Excel File" to anything you want: Ex: VALUE="Click Here to open my spreadsheet"
Disclaimer: We hope that the information in these pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by me. I shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.