parevr23
08-12-2007, 10:03 AM
Hi,
I have an Excel document that runs macros and that will be hosted on a web site so that multiple users can access and run the file. In the site I have a link the users click on to open the file.
When I click on the link, Excel is automatically open in Internet Explorer. I notice that when the file is opened in IE, I get multiple errors in the macros. I realize that the Excel plug-in for IE may not be able to run my macros and so I don't want IE to open the file.
I did some research and I found out that I can change the configuration of my computers to prevent IE to open excel files. However, this is not a good solution because I would have to force many users to change settings in their individual computers they may not familiar with or may not have privileges to change. I then found a VBScript on-line that would prevent IE to open the Excel file but I had some problems with it:
<HTML>
<HEAD>
<SCRIPT LANGUAGE=VBScript>
Dim objExcel
Sub btnOpen_onclick()
Dim path
path = "C:\myfile.xls"
call OpenWorkbook(path)
End Sub
Sub OpenWorkbook(strLocation)
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
objExcel.Workbooks.Open strLocation
objExcel.UserControl = true
End Sub
</SCRIPT>
</SCRIPT>
<TITLE>Launch Excel</Title>
</HEAD>
<BODY>
When I run this script from c:\ it works perfectly. However, when I upload this html file to my website and try to open the excel file I get the following error:
Error: ActiveX component can't create object: 'Excel.Application'
The error happens here: Set objExcel = CreateObject("Excel.Application")
Thanks in advance for your help
I have an Excel document that runs macros and that will be hosted on a web site so that multiple users can access and run the file. In the site I have a link the users click on to open the file.
When I click on the link, Excel is automatically open in Internet Explorer. I notice that when the file is opened in IE, I get multiple errors in the macros. I realize that the Excel plug-in for IE may not be able to run my macros and so I don't want IE to open the file.
I did some research and I found out that I can change the configuration of my computers to prevent IE to open excel files. However, this is not a good solution because I would have to force many users to change settings in their individual computers they may not familiar with or may not have privileges to change. I then found a VBScript on-line that would prevent IE to open the Excel file but I had some problems with it:
<HTML>
<HEAD>
<SCRIPT LANGUAGE=VBScript>
Dim objExcel
Sub btnOpen_onclick()
Dim path
path = "C:\myfile.xls"
call OpenWorkbook(path)
End Sub
Sub OpenWorkbook(strLocation)
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
objExcel.Workbooks.Open strLocation
objExcel.UserControl = true
End Sub
</SCRIPT>
</SCRIPT>
<TITLE>Launch Excel</Title>
</HEAD>
<BODY>
When I run this script from c:\ it works perfectly. However, when I upload this html file to my website and try to open the excel file I get the following error:
Error: ActiveX component can't create object: 'Excel.Application'
The error happens here: Set objExcel = CreateObject("Excel.Application")
Thanks in advance for your help