Hi I am a New bie in Vb script what I am trying to do is that I am checking the tab name if RBS site is not found then it should end otherwise it should continue the code.Please help me
<PACKAGE>
<JOB ID=Submit_Reminder>
<SCRIPT LANGUAGE="VBScript" SRC="c:\test\clearquest.bas"/>
<SCRIPT >
dim flag_rnc, objSheet, rxfl
dim flag_rxi, strRNC , strMarket, strRegion, strMarketPhase, strRXI, final_ch
sy = 0
final_ch = 0
rxfl = 0
'--------------------------------------------------------------------------------------------
Set objFSO = createobject("scripting.filesystemobject")
Set objtxtStream = objFSO.CreateTextFile("c:\test\log.txt", True)
'--------------------------------------------------------------------------------------------
Set WSHShell = WScript.CreateObject("WScript.Shell")
' We are ready to use the InputBox-function
' InputBox (prompt, title, default, xpos, ypos)
' prompt: the text shown in the input box
' title: the title shown in the input box
' default: the value shown as default in the input field
' xpos/xpos: upper left corner of the input box
' if some values are omitted, WSH uses default values
filnam = InputBox("Enter the Input file name","File Check","File name", 100, 100)
pathnm = "c:\test\"&filnam&".xls"
'dim fs
Set fs = CreateObject("scripting.filesystemobject")
if not fs.fileexists(pathnm) then
Wscript.echo "File doesn't exist - Check file name!!"
Wscript.Quit
end if
'end if
' end if 'end of successful session
'--------------------------------------------------------------------------------------------
' Bind to Excel object.
On Error Resume Next
Set objExcel = CreateObject("Excel.Application")
If (Err.Number <> 0) Then
On Error GoTo 0
Wscript.Echo "Excel application not found."
Wscript.Quit
End If
On Error GoTo 0
strExcelPath = "c:\test\"&filnam&".xls"
' Open specified spreadsheet and select the first worksheet.
objExcel.WorkBooks.Open strExcelPath
if objExcel.ActiveWorkbook.Worksheets("RBS Site") <> "RBS Site" then
---error here
objtxtStream.Writeline "Error in RBS Site Tab"
else
Set objSheet = objExcel.ActiveWorkbook.Worksheets("RBS Site")
objExcel.ActiveWorkbook.Worksheets("RBS Site").Range("A1:T10000").Value = objExcel.ActiveWorkbook.Worksheets("RBS Site").Range("A1:T10000").Value
' checks decimal values
dim i,k ,j, isFloat, toTest
isfloat=false
toTest = "hello"
i=0
For j= 2 to 10000
For k= 2 to 11
toTest = objExcel.ActiveWorkbook.Worksheets("RBS Site").cells(j,k).Value
i=instr(1,toTest,".",vbTextCompare)
if i>0 and k <>5 then
isFloat=true
objtxtStream.Writeline "Decimal number in RBS Site - Row: " & j & " Column : " & k
k=k+8
end If
Next
Next
' Iterate through the rows of the spreadsheet after the first, until the
' first blank entry in the first column. For each row, bind to the user
' specified in the first column and set attributes.
intRow = 2
if (objSheet.Cells(1,1).Value <> "rncId" ) then
objtxtStream.Writeline "Error in RBS Site : Cells(1,1)"
end if
if (objSheet.Cells(1,2).Value <> "rbsId" ) then
objtxtStream.Writeline "Error in RBS Site : Cells(1,2)"
end if
if (objSheet.Cells(1,3).Value <> "Site Id" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,3)"
end if
if (objSheet.Cells(1,4).Value <> "logicalName" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,4)"
end if
if (objSheet.Cells(1,5).Value <> "Street Address" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,5)"
end if
if (objSheet.Cells(1,6).Value <> "City" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,6)"
end if
if (objSheet.Cells(1,7).Value <> "Structure Type" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,7)"
end if
if (objSheet.Cells(1,8).Value <> "rbsType" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,8)"
end if
if (objSheet.Cells(1,9).Value <> "redundancy" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,9)"
end if
if (objSheet.Cells(1,10).Value <> "typeOfPowerSupply" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,10)"
end if
if (objSheet.Cells(1,11).Value <> "noOfPsu" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,11)"
end if
if (objSheet.Cells(1,12).Value <> "batteryBackup" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,12)"
end if
if (objSheet.Cells(1,13).Value <> "batteryCapacity" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,13)"
end if
if (objSheet.Cells(1,14).Value <> "xalmConfig" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,14)"
end if
end if
Wscript.Echo "Input File Check Done. Please View the log file! "
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
' Clean up.
Set objExcel = Nothing
Set objSheet = Nothing
Set objUser = Nothing
</SCRIPT>
</JOB>
</PACKAGE>
<PACKAGE>
<JOB ID=Submit_Reminder>
<SCRIPT LANGUAGE="VBScript" SRC="c:\test\clearquest.bas"/>
<SCRIPT >
dim flag_rnc, objSheet, rxfl
dim flag_rxi, strRNC , strMarket, strRegion, strMarketPhase, strRXI, final_ch
sy = 0
final_ch = 0
rxfl = 0
'--------------------------------------------------------------------------------------------
Set objFSO = createobject("scripting.filesystemobject")
Set objtxtStream = objFSO.CreateTextFile("c:\test\log.txt", True)
'--------------------------------------------------------------------------------------------
Set WSHShell = WScript.CreateObject("WScript.Shell")
' We are ready to use the InputBox-function
' InputBox (prompt, title, default, xpos, ypos)
' prompt: the text shown in the input box
' title: the title shown in the input box
' default: the value shown as default in the input field
' xpos/xpos: upper left corner of the input box
' if some values are omitted, WSH uses default values
filnam = InputBox("Enter the Input file name","File Check","File name", 100, 100)
pathnm = "c:\test\"&filnam&".xls"
'dim fs
Set fs = CreateObject("scripting.filesystemobject")
if not fs.fileexists(pathnm) then
Wscript.echo "File doesn't exist - Check file name!!"
Wscript.Quit
end if
'end if
' end if 'end of successful session
'--------------------------------------------------------------------------------------------
' Bind to Excel object.
On Error Resume Next
Set objExcel = CreateObject("Excel.Application")
If (Err.Number <> 0) Then
On Error GoTo 0
Wscript.Echo "Excel application not found."
Wscript.Quit
End If
On Error GoTo 0
strExcelPath = "c:\test\"&filnam&".xls"
' Open specified spreadsheet and select the first worksheet.
objExcel.WorkBooks.Open strExcelPath
if objExcel.ActiveWorkbook.Worksheets("RBS Site") <> "RBS Site" then
---error here
objtxtStream.Writeline "Error in RBS Site Tab"
else
Set objSheet = objExcel.ActiveWorkbook.Worksheets("RBS Site")
objExcel.ActiveWorkbook.Worksheets("RBS Site").Range("A1:T10000").Value = objExcel.ActiveWorkbook.Worksheets("RBS Site").Range("A1:T10000").Value
' checks decimal values
dim i,k ,j, isFloat, toTest
isfloat=false
toTest = "hello"
i=0
For j= 2 to 10000
For k= 2 to 11
toTest = objExcel.ActiveWorkbook.Worksheets("RBS Site").cells(j,k).Value
i=instr(1,toTest,".",vbTextCompare)
if i>0 and k <>5 then
isFloat=true
objtxtStream.Writeline "Decimal number in RBS Site - Row: " & j & " Column : " & k
k=k+8
end If
Next
Next
' Iterate through the rows of the spreadsheet after the first, until the
' first blank entry in the first column. For each row, bind to the user
' specified in the first column and set attributes.
intRow = 2
if (objSheet.Cells(1,1).Value <> "rncId" ) then
objtxtStream.Writeline "Error in RBS Site : Cells(1,1)"
end if
if (objSheet.Cells(1,2).Value <> "rbsId" ) then
objtxtStream.Writeline "Error in RBS Site : Cells(1,2)"
end if
if (objSheet.Cells(1,3).Value <> "Site Id" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,3)"
end if
if (objSheet.Cells(1,4).Value <> "logicalName" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,4)"
end if
if (objSheet.Cells(1,5).Value <> "Street Address" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,5)"
end if
if (objSheet.Cells(1,6).Value <> "City" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,6)"
end if
if (objSheet.Cells(1,7).Value <> "Structure Type" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,7)"
end if
if (objSheet.Cells(1,8).Value <> "rbsType" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,8)"
end if
if (objSheet.Cells(1,9).Value <> "redundancy" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,9)"
end if
if (objSheet.Cells(1,10).Value <> "typeOfPowerSupply" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,10)"
end if
if (objSheet.Cells(1,11).Value <> "noOfPsu" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,11)"
end if
if (objSheet.Cells(1,12).Value <> "batteryBackup" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,12)"
end if
if (objSheet.Cells(1,13).Value <> "batteryCapacity" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,13)"
end if
if (objSheet.Cells(1,14).Value <> "xalmConfig" ) then
objtxtStream.Writeline "Error in RBS Site: Cells(1,14)"
end if
end if
Wscript.Echo "Input File Check Done. Please View the log file! "
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
' Clean up.
Set objExcel = Nothing
Set objSheet = Nothing
Set objUser = Nothing
</SCRIPT>
</JOB>
</PACKAGE>