B
benazir
Hi,
How should we handle the exceptions/errors in the Excel?
I am using the following code, but during running it gave some errors.
I wanted that if the error occurs during running, it would be handled
automatically.
What extra piece of code I add in order to handle the error?
Any suggestion will be appreciated.
I am getting the error like:
a. File not found
b. Object required.
Regards
BENAZIR
CODE:
Sub ArchivelogChk
'This module checks you are in archivelog mode, and aborts the entire
thing
'if not. No point in trying to perform a hot backup unless you are.
strFileOut="archive.sql"
strBp="set trimspool on" & chr(10) & "set heading off" & chr(10)
&"set feedback off" & chr(10) & "set echo off" & chr(10) & "spool
arcchk.txt"
set objFS=CreateObject("Scripting.FileSystemObject")
set objOutFile=objFS.OpenTextFile(strFileOut,2,1)
strOutput=strBp & chr(10) & "select log_mode from v$database;" &
chr(10) & "spool off" & chr(10) & "exit"
objOutFile.WriteLine strOutput
Set WshShell=CreateObject("WScript.Shell")
WshShell.Run "sqlplus system/dizwell @archive.sql"
strArchive="arcchk.txt"
set objArchive=objFS.OpenTextFile(strArchive,1,0)
While Not objArchive.AtEndOfStream
strInput=objArchive.ReadLine
if strInput="" then
else
If strInput<>"ARCHIVELOG" Then
title = "Fatal Error!"
Wscript.Echo "Not in Archivelog Mode! Hot Backups not possible!
Aborting!"
set objFile=Nothing
set objOutFile=Nothing
set objArchive=Nothing
set objFS=CreateObject("Scripting.FileSystemObject")
objFS.DeleteFile "arcchk.txt"
objFS.DeleteFile "archive.sql"
End If
End If
wend
set objFile=Nothing
set objOutFile=Nothing
set objArchive=Nothing
End Sub
How should we handle the exceptions/errors in the Excel?
I am using the following code, but during running it gave some errors.
I wanted that if the error occurs during running, it would be handled
automatically.
What extra piece of code I add in order to handle the error?
Any suggestion will be appreciated.
I am getting the error like:
a. File not found
b. Object required.
Regards
BENAZIR
CODE:
Sub ArchivelogChk
'This module checks you are in archivelog mode, and aborts the entire
thing
'if not. No point in trying to perform a hot backup unless you are.
strFileOut="archive.sql"
strBp="set trimspool on" & chr(10) & "set heading off" & chr(10)
&"set feedback off" & chr(10) & "set echo off" & chr(10) & "spool
arcchk.txt"
set objFS=CreateObject("Scripting.FileSystemObject")
set objOutFile=objFS.OpenTextFile(strFileOut,2,1)
strOutput=strBp & chr(10) & "select log_mode from v$database;" &
chr(10) & "spool off" & chr(10) & "exit"
objOutFile.WriteLine strOutput
Set WshShell=CreateObject("WScript.Shell")
WshShell.Run "sqlplus system/dizwell @archive.sql"
strArchive="arcchk.txt"
set objArchive=objFS.OpenTextFile(strArchive,1,0)
While Not objArchive.AtEndOfStream
strInput=objArchive.ReadLine
if strInput="" then
else
If strInput<>"ARCHIVELOG" Then
title = "Fatal Error!"
Wscript.Echo "Not in Archivelog Mode! Hot Backups not possible!
Aborting!"
set objFile=Nothing
set objOutFile=Nothing
set objArchive=Nothing
set objFS=CreateObject("Scripting.FileSystemObject")
objFS.DeleteFile "arcchk.txt"
objFS.DeleteFile "archive.sql"
End If
End If
wend
set objFile=Nothing
set objOutFile=Nothing
set objArchive=Nothing
End Sub