Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 25th, 2004, 02:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default To access "EXCEL" object

Hi All,

I would like to know the steps to access "EXCEL" object in ASP 3.0.
Which DLL needs to be registered?

Thanks for your help,

mcinar


__________________
MCinar

Love all the creatures because of the creator.
 
Old November 26th, 2004, 12:27 AM
Authorized User
 
Join Date: Aug 2003
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Pls check this link. You will find a code sample of using excel object. You dont need to register any dll if u have MS Office installed.

http://www.codetoad.com/forum/16_23684.asp


 
Old November 26th, 2004, 02:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

check out http://www.greggriffiths.org/webdev/both/excel/ as well.
 
Old November 26th, 2004, 09:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank you, leo.
I checked this site and it is very helpful.

mcinar

 
Old November 28th, 2004, 03:21 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank you, Greg.
I checked this site and it is very helpful.

mcinar


 
Old November 28th, 2004, 05:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Leo and Greg,
Thanks for your help. Those sites were very helpful.
But, I am still having a problem to access the "EXCEL" object at this code;

Dim Xcl
Set Xcl = Server.CreateObject("Excel.Application")

I get the following error;

"Technical Information (for support personnel)
Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid ProgID. For additional information specific to this message please visit the Microsoft Online Support site located at: http://www.microsoft.com/contentredirect.asp.
/test-xhtml/Excel_TEST_2.asp, line 9"


Here is the complete code;

<%@ Language=VBScript %>
<% option explicit

StartExcel

Sub StartExcel
 Dim Xcl

  set Xcl = server.CreateObject "Excel.Apllication")
  xcl.Visible = true

  set newBook = Xcl.Workbooks.Add
  newBook = Xcl.WorkSheets(1).Activate
  newBook.WorkSheets(1).Cells(1,1).Value="Value1"
  newBook.WorkSheets(1).Name="My First WorkSheet"

  set Xcl = Nothing
  set newBook = Nothing
End Sub
%>

I have EXCEL installed and I didn't have to register any DLL to access the "EXCEL" object.

Any advice?

Thanks for your help,

mcinar

 
Old November 29th, 2004, 12:13 AM
Authorized User
 
Join Date: Aug 2003
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You havent supplied the opening bracket in the createObject as well as the spelling of application is incorrect.
As per your code:
set Xcl = server.CreateObject "Excel.Apllication") ' Wrong
set Xcl = server.CreateObject ("Excel.Application") 'Correct

That will solve your problem.

Vinay
 
Old November 30th, 2004, 12:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Leo,

You are right with the spelling.
It is now working. Only problem that I am having is
when I tried to use the following code;

strFileName = oXL.GetSaveAsFileName("Test1.xls")

This code is supposed to bring up the "Save as Dialog Box" for user to decide where to save the file and you can also change the file name .

IE hangs and it doesn't do anything.

Here is the full code;

<%@ Language=VBScript %>
<% option explicit

StartExcel

Sub StartExcel
  Dim oXL, oWB, oSheet, strFileName, fso, strPath

  strFileName = "Excel_Test1.xls"

  set oXL = server.CreateObject("Excel.Application")

  oXL.Application.Visible = true
  oXL.WorkBooks.Add

  set oWB = oxl.workbooks(1)
  set oSheet = oWb.Worksheets(1)
  oSheet.activate

  oSheet.Range("A1" & ":B1").MergeCells = true
  oSheet.Cells(1,1) = "2005 - Budget"
  oSheet.Cells(1,1).Font.Size = 15
  oSheet.Cells(1,1).font.fontstyle = "bold"

  strPath = server.MapPath("/EXCEL_FILES/" &
     strFileName)

   set fso =
     server.CreateObject"scripting.filesystemobject")

     strFileName = oXL.Application.GetSaveAsFileName
          ("Test1.xls")

     if strFileName = false then
       strFileName = "Test1.xls"
     end if


     if fso.FileExists(strPath) then
       fso.DeleteFile(strPath)
     end if

     osheet.saveas strPath
     owb.close


     set oXL = Nothing
     set oWB = Nothing
     set oSheet = Nothing
     set fso = Nothing
End Sub
%>

Thank you,

mcinar






Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Chart Object In Access Report dorlesky Access VBA 0 July 26th, 2007 10:26 PM
Excel Object dpkbahuguna Beginning VB 6 0 January 29th, 2007 01:51 AM
Converting excel data to Access using excel VBA ShaileshShinde VB Databases Basics 1 April 26th, 2006 07:57 AM
Connecting to Excel in Access OLE Object Mack Classic ASP Databases 0 October 8th, 2004 03:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.