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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript Code In IE That Opens Excel WorkBook Not Running In XP 2

Status
Not open for further replies.

Rob94

Programmer
Mar 30, 2004
19
US
I am currently working on an .asp application that manipulates
Excel from a web page using VBScript. The application
works fine on an NT platform, but it needs to be modified to
work under Windows XP. I am having problems with the section
of code described below. Here is what is happening:


Code:
'======================================
' I define the variable globally first
'======================================
Dim xlobject ' Defined globally
Set xlobject = GetObject(,"excel.application")


'=================================================
' The code snippet listed below is where the
' problem occurs.  
' CS_sSpreadsheetPath & sMasterWorkbookFileName
' form a fully qualified path to an existing .xls 
' file.
'=================================================

On Error Resume Next

Dim xlMasterWorkbook
set xlMasterWorkbook = xlobject.workbooks.open(CS_sSpreadsheetPath & sMasterWorkbookFileName)

if err.number <> 0 then
	msgbox "Error number " & err.number & ":  " & err.description		
	err.clear	
	exit sub
end if

'=======================
' End of code snippet
'=======================

When the code snippet above executes, a messagebox pops up
with the following error: "Error number 1004: Unable to
get the Open property of the Workbooks class." Ok, here is
where it gets crazy. If I put a STOP statement after the
"On Error Resume Next", and step through the code in "debug"
mode (using Visual InterDev), everything works fine. Does
anyone have any suggestions as to how to make it work WITHOUT the STOP statement? Any suggestions would be greatly appreciated.
 
Have you tried this ?
Dim xlobject ' Defined globally
Dim xlMasterWorkbook
Set xlMasterWorkbook = GetObject(CS_sSpreadsheetPath & sMasterWorkbookFileName)
Set xlobject = xlMasterWorkbook.Application


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Hello Rob94,

If you have less than 100% confidence you have an instance of excel there already, then trap error up there as well.
Code:
on error resume next
Set xlobject = GetObject(,"excel.application")
if err.number<>0 then
    set xlobject=server.createobject("excel.application")
    err.clear
end if
regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top