Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CreateObject("Excel.Application")

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
This works locally on an html page just fine - but when I put it on a sverer on asp I get the following error:

ActiveX component can't create object: Excel.Application

Is something missing from the server?

Code:
<SCRIPT LANGUAGE=VBScript>
     Dim objExcel
     Sub Btn1_onclick()
	 call OpenWorkbook("C:\Inetpub\[URL unfurl="true"]wwwroot\folder\file.xls")[/URL]
     End Sub
							
     Sub OpenWorkbook(strLocation)
	Set objExcel = CreateObject("Excel.Application")
	objExcel.Visible = true
	objExcel.Workbooks.Open strLocation
	objExcel.UserControl = true
     End Sub
</SCRIPT>

<a href="#" class="contentsw" NAME='Btn1'>Link</a>	

[conehead]
 
Does the machine that the code is running on have Excel installed? Are the security settings low enough to allow the code to create the object?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
yes - it does have excel installed - the security settings should be good - is there anything inparticular you would suggest I check?

[conehead]
 
make sure the IUSR_MachineName and IWAM_MachineName has the correct permissions...

-DNG
 
ConeHead - What is it that you are trying to do? Open a current spreadsheet or create a new one?


To look at old ones (and even edit them) you should look into
Code:
Set excelApp = Server.CreateObject("Excel.Application")
			excelApp.Workbooks.Open Server.MapPath("../uploads/lrt/abstracts/" & lseAbs),false, true

For creating them from your ASP page, look at XML
Code:
dim act
Set act = fso.CreateTextFile(fileName, true)
with act
	.WriteLine "<html xmlns:x=""urn:schemas-microsoft-com:office:excel"">"
	.WriteLine "<head>"
	.WriteLine "<!--[if gte mso 9]><xml>"
	.WriteLine "<x:ExcelWorkbook>"
		.WriteLine "<x:ExcelWorksheets>"
			.WriteLine "<x:ExcelWorksheet>"
			.WriteLine "<x:Name>" & cbr & "</x:Name>"
				.WriteLine "<x:WorksheetOptions>"
					.WriteLine "<x:PageSetup>"
						.WriteLine "<x:Header>" & CBR & "</x:Header>"
					.WriteLine "</x:PageSetup>"
					.WriteLine "<x:Print>"
						.WriteLine "<x:ValidPrinterInfo/>"
					.WriteLine "</x:Print>"
			.WriteLine "</x:WorksheetOptions>"
			.WriteLine "</x:ExcelWorksheet>"
		.WriteLine "</x:ExcelWorksheets>"
	.WriteLine "</x:ExcelWorkbook>"
	.WriteLine "</xml>"
	.WriteLine "<![endif]--> "
	.WriteLine "</head>"
	.WriteLine [blue]write an HTML table here and it is written as an Excel Sheet[/blue]
end with
act.close

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
I am wanting to open an existing .xls but NOT open it in a browser window - but rather have it open in the excel app....

[conehead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top