|
|
 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

September 12th, 2006, 03:45 PM
|
|
Registered User
|
|
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How to Run Excel Macros from ASP
Hi Friends,
Hope you all are doing well.
I want to call an existing Excel macro from ASP.
I see many variations of...
Set objExcel = New Server.createobject("Excel.Application")
.
.
.
objExcel.Run("macro-name")
but doesn't work.
My ASP doesn't seem to understand Excel.Application and .Run command.
Need help ASAP.
Thanks,
Regards,
|

September 12th, 2006, 04:46 PM
|
|
Wrox Author
Points: 12,827, Level: 49 |
|
|
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,029
Thanks: 1
Thanked 42 Times in 42 Posts
|
|
What are you error messages?
"The one language all programmers understand is profanity."
|

September 13th, 2006, 10:49 AM
|
|
Registered User
|
|
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
In my Excel I have a simple function that inserts 1 into range("A1")
Sub test()
Range("a1") = 1
End Sub
The ASP script looks like this:
Dim cnnExcel
Set cnnExcel = server.CreateObject("ADODB.connection")
cnnExcel.open "DBQ=" & Server.MapPath("fpdb/book1.xls") & ";" & _
"DRIVER={Microsoft Excel Driver (*.xls)};"
cnnExcel.Run("test")
With error message:
# Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'Run'. Make sure the object exists and that you spell its name and the path name correctly.
/testexcel.asp, line 25
When I try ASP script:
Dim xls
Dim cnnExcel
Set cnnExcel = server.CreateObject("ADODB.connection")
cnnExcel.open "DBQ=" & Server.MapPath("fpdb/book1.xls") & ";" & _
"DRIVER={Microsoft Excel Driver (*.xls)};"
Set xls = Server.CreateObject("Excel.Application")
The ASP doesn't recognize Excel.Application causes this error message:
* Error Type:
Server object, ASP 0178 (0x80070005)
The call to Server.CreateObject failed while checking permissions. Access is denied to this object.
/testexcel.asp, line 22
Any Help?
|

September 13th, 2006, 11:03 AM
|
|
Wrox Author
Points: 12,827, Level: 49 |
|
|
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,029
Thanks: 1
Thanked 42 Times in 42 Posts
|
|
Why are you trying to create an ADO connection to the Excel workbook?? The reason, in your first example, that the Jet Driver doesn't recoginize .Run is because .Run isn't part of an ADO object.
What you should be doing is something like this:
Dim xls
Set xls = CreateObject("Excel.Application")
xls.Workbooks.Open [Path to excel file], 3, False
xls.Run("[workbook].[macro]")
set xls = Nothing
"The one language all programmers understand is profanity."
|

September 13th, 2006, 11:14 AM
|
|
Registered User
|
|
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
with the code above I get this message.
Error Type:
Microsoft VBScript runtime (0x800A0046)
Permission denied: 'CreateObject'
Can someone tell me why its denying me permission to createobject? The excel isn't read-only and I am the admin.
|

September 13th, 2006, 11:18 AM
|
|
Wrox Author
Points: 12,827, Level: 49 |
|
|
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,029
Thanks: 1
Thanked 42 Times in 42 Posts
|
|
Try Server.CreateObject though that shouldnt make a difference. What you may want to look at is the premissions of the folder the excel file resides in.
"The one language all programmers understand is profanity."
|

September 13th, 2006, 11:25 AM
|
|
Registered User
|
|
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
With that I've got:
The call to Server.CreateObject failed while checking permissions. Access is denied to this object.
I've also tried New server.createobject, New createobject with no success.
But createobject(ADODB.connection) and createobject(ADODB.recordset) works. So my createobject is fine its just that its preventing me access to Excel.Application for some reason.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |