B
benazir
Hi,
We run the following macro in EXCEL in order to perform OS Backup, but
we got the errors like:
For Example:
When we run the following macro in Excel, we got errors like:
1. Object required for (Wscript.sleep 15000)
2. Object required for (Wscript.Echo "Not in Archivelog Mode!
Hot Backups not
possible! Aborting!")
3. File Not found (strArchive = "arcchk.txt) (Set objArchive =
objFS.OpenTextFile(strArchive, 1, 0)
I think we have to define some variables in order to run that macro
successfully.
Could someone please suggest about my problem?
Below we found the code.
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/manager @archive.sql"
Wscript.sleep 15000
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"
Wscript.Quit 1
End If
End If
wend
set objFile=Nothing
set objOutFile=Nothing
set objArchive=Nothing
End Sub
We run the following macro in EXCEL in order to perform OS Backup, but
we got the errors like:
For Example:
When we run the following macro in Excel, we got errors like:
1. Object required for (Wscript.sleep 15000)
2. Object required for (Wscript.Echo "Not in Archivelog Mode!
Hot Backups not
possible! Aborting!")
3. File Not found (strArchive = "arcchk.txt) (Set objArchive =
objFS.OpenTextFile(strArchive, 1, 0)
I think we have to define some variables in order to run that macro
successfully.
Could someone please suggest about my problem?
Below we found the code.
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/manager @archive.sql"
Wscript.sleep 15000
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"
Wscript.Quit 1
End If
End If
wend
set objFile=Nothing
set objOutFile=Nothing
set objArchive=Nothing
End Sub