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!

Response.Redirect in VBScript

Status
Not open for further replies.

ISPrincess

Programmer
Feb 22, 2002
318
US
I know I must be doing (or not doing) something really stupid but my response.redirect is not working in asp page within vbscript.

I am purposefully creating an error and do not get redirected to errorpage. (bolded line)

I have code as follows:
<script language=&quot;VBScript&quot;>
dim excelapptmp

on error resume next

Set excelAppTmp = createobject(&quot;excel.Application&quot;)

if err.number then response.redirect (&quot;ErrorDisplay.asp?ErrorString=ActiveX&quot;)
</script>

Please help!
 
Actually here is the ENTIRE Pages code from Top 2 bot.

<%@ Language=VBScript %>
<% Option Explicit
Response.Buffer = true%>
<script language=&quot;VBScript&quot;>
Dim excelApp
Dim worksheet
Dim sheet
dim queryTables
dim queryTable
dim cellrange
dim dataURL
dim excelAppTmp
dim WshShell

on error resume next

'set WshShell = CreateObject(&quot;WScript.Shell&quot;)
'WshShell.AppActivate(&quot;Microsoft Excel&quot;)
'Set WshShell = Nothing

Set excelAppTmp = createobject(&quot;excel.Application&quot;)

if err.number then response.redirect(&quot;ErrorDisplay.asp?ErrorString=ActiveX&quot;)

on Error Goto 0

Set excelApp = createobject(&quot;excel.Application&quot;)
excelApp.Visible = True
Set worksheet = excelApp.Workbooks.Add
worksheet.activate
Set sheet = worksheet.Sheets(1)
sheet.Activate
set queryTables = sheet.querytables
'set queryTable = queryTables.Add(&quot;URL; sheet.Range(&quot;A1&quot;))
set queryTable = queryTables.Add(&quot;URL; sheet.Range(&quot;A1&quot;))
queryTable.Name = &quot;AlertReport&quot;
queryTable.FieldNames = True
queryTable.RowNumbers = False
queryTable.FillAdjacentFormulas = False
'queryTable.PreserveFormatting = True
queryTable.RefreshOnFileOpen = False
queryTable.BackgroundQuery = True
queryTable.RefreshStyle = xlInsertDeleteCells
queryTable.SavePassword = True
queryTable.SaveData = True
'queryTable.AdjustColumnWidth = True
'queryTable.RefreshPeriod = 0
queryTable.Refresh
'document.all(&quot;message&quot;).innertext = &quot;Switch to the Excel window to view the data.&quot;
excelAppTmp.Quit
set excelAppTmp = nothing
excelApp.Visible = True

</script>
 
The below script is client side not server side.
Response.redirect is a server side method of the response object
<script language=&quot;VBScript&quot;>
Dim excelApp
Dim worksheet
Dim sheet
dim queryTables
dim queryTable
dim cellrange
dim dataURL
dim excelAppTmp
dim WshShell

on error resume next

'set WshShell = CreateObject(&quot;WScript.Shell&quot;)
'WshShell.AppActivate(&quot;Microsoft Excel&quot;)
'Set WshShell = Nothing

Set excelAppTmp = createobject(&quot;excel.Application&quot;)

if err.number then response.redirect(&quot;ErrorDisplay.asp?ErrorString=ActiveX&quot;)

on Error Goto 0

Set excelApp = createobject(&quot;excel.Application&quot;)
excelApp.Visible = True
Set worksheet = excelApp.Workbooks.Add
worksheet.activate
Set sheet = worksheet.Sheets(1)
sheet.Activate
set queryTables = sheet.querytables
'set queryTable = queryTables.Add(&quot;URL; sheet.Range(&quot;A1&quot;))
set queryTable = queryTables.Add(&quot;URL; sheet.Range(&quot;A1&quot;))
queryTable.Name = &quot;AlertReport&quot;
queryTable.FieldNames = True
queryTable.RowNumbers = False
queryTable.FillAdjacentFormulas = False
'queryTable.PreserveFormatting = True
queryTable.RefreshOnFileOpen = False
queryTable.BackgroundQuery = True
queryTable.RefreshStyle = xlInsertDeleteCells
queryTable.SavePassword = True
queryTable.SaveData = True
'queryTable.AdjustColumnWidth = True
'queryTable.RefreshPeriod = 0
queryTable.Refresh
'document.all(&quot;message&quot;).innertext = &quot;Switch to the Excel window to view the data.&quot;
excelAppTmp.Quit
set excelAppTmp = nothing
excelApp.Visible = True

</script>

try this
if err.number then window.location=&quot;ErrorDisplay.asp?ErrorString=ActiveX&quot;

you may need the whole path(if
for this

if err.number then response.redirect(&quot;ErrorDisplay.asp?ErrorString=ActiveX&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top