yon-cuadrado
11/8/2019 - 7:09 PM

common-functions.vbs


'check if a file exists

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FileExists(strFileNameAndPath) Then
   fso.DeleteFile(strFileNameAndPath)
End If

'check if a variable is numeric without obtaining errors

isnumeric()

'How to write in a dictionary. dictJoinedFiles is the dictionary object
myArray = dictJoinedFiles.Item("0ReferenceColumnSourceFile")
myArray(0) = 3
dictJoinedFiles.Item("0ReferenceColumnSourceFile") = myArray

' How to format date in a correct format with two digits in month and day
'FormatDateTime = Function to format the dates with two digits in each part. Example

dtmDate1 = "1/4/2011"

FormatDateTime(dtmDate1,2) = "01/04/2011"

' get the background color of a webedit

CR_Color = Browser("Default").Page("Default_3").WebEdit("ctl00$DC$txtShape_CR").Object.currentStyle.BackgroundColor 

'*************************************************************************************************************************************************'
' FUNCTIONS AND SUBRUTINES
'*************************************************************************************************************************************************'

'Function pad_leading_zeroes(input, total_length)
'Description: This function adds zeros at the begining of a number to make it to have the length provided in the parameter total_length
'Parameters:
'input = Number to which the zeros will be added
'total_length = Length that the number has to have

'Sub Clear_Temp_Files()
'Description: This subrutine deletes the temp files of the internet explorer browser

'Sub Clear_Cookies()
'Description: This subrutine deletes the cookies files of the internet explorer browser

'Sub Clear_History()
'Description: This subrutine deletes the history of the internet explorer browser

'Sub Clear_Form_Data()
'Description: This subrutine deletes the form data of the internet explorer browser

'Sub Clear_Saved_Passwords()
'Description: This subrutine deletes the saved passwords of the internet explorer browser

'Sub Clear_All()
'Description: This subrutine deletes the saved passwords, the form data, the cookies, the history and the temp files  
'             of the internet explorer browser

'Sub Clear_Clear_Add_ons_Settings()
'Description: This subrutine deletes the addon settings of the internet explorer browser

'Function fCompressFiles(strObject,strFileOrFolder,strCompressedResultsFile)
'Description: This function compresses the files of one folder that is provided as a parameter.

'Function fConvert_data_from_SAPFormat_to_ExcelFormat (ByVal strData, ByVal strDataProfile)
'Description: This function converts data from SAP format to excel format

'Function fConvert_data_from_ExcelFormat_to_SAPFormat (ByVal strData, ByVal strDataProfile)
'Description: This function converts data from excel format to SAP format

'Function fReadFile(ByVal strFileNameAndPath)
'Description: This function reads a text file

'Function fCloseProcessesByName(ByVal strProcessName)
'Description: This function closes all the open proceses in task manager with the given name

'Function fWaitForProcess(ByVal strProcessName)
'Description: This function waits for a process to appear in the tasks list

'Function fSendEmailWithSMPT(ByVal strFrom, ByVal strTo, ByVal strCC, ByVal strSubject, ByVal strBody, ByVal strAttachment)
'Description: This function sends an email using SMTP program




'*************************************************************************************************************************************************'
' FUNCTIONS AND SUBRUTINES
'*************************************************************************************************************************************************'


'*************************************************************************************************************************************************'
'Function pad_leading_zeroes(input, total_length)
'Description: This function adds zeros at the begining of a number to make it to have the length provided in the parameter total_length
'Date:11/08/2013
'Author: Yon Cuadrado

'Parameters:
'input = Number to which the zeros will be added
'total_length = Length that the number has to have

'Return value
' it returns the input string with the length of the parameter total_length
'*************************************************************************************************************************************************'
Function pad_leading_zeroes(input, total_length)
   pad_leading_zeroes = String(total_length - len(input), "0") & input
End Function

'*************************************************************************************************************************************************'
'Sub Clear_Temp_Files()
'Description: This subrutine deletes the temp files of the internet explorer browser
'Date:11/09/2013
'Author: Yon Cuadrado
'*************************************************************************************************************************************************'
Sub Clear_Temp_Files()
    Dim WshShell
    Set WshShell = CreateObject("wscript.Shell") 
    WshShell.Run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 "
End Sub	

'*************************************************************************************************************************************************'
'Sub Clear_Cookies()
'Description: This subrutine deletes the cookies files of the internet explorer browser
'Date:11/09/2013
'Author: Yon Cuadrado
'*************************************************************************************************************************************************'
Sub Clear_Cookies()
    Dim WshShell
    Set WshShell = CreateObject("wscript.Shell") 
    WshShell.Run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2"
End Sub

'*************************************************************************************************************************************************'
'Sub Clear_History()
'Description: This subrutine deletes the history of the internet explorer browser
'Date:11/09/2013
'Author: Yon Cuadrado
'*************************************************************************************************************************************************'
Sub Clear_History()
    Dim WshShell
    Set WshShell = CreateObject("wscript.Shell") 
    WshShell.Run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1"
End Sub

'*************************************************************************************************************************************************'
'Sub Clear_Form_Data()
'Description: This subrutine deletes the form data of the internet explorer browser
'Date:11/09/2013
'Author: Yon Cuadrado
'*************************************************************************************************************************************************'
Sub Clear_Form_Data()
    Dim WshShell
    Set WshShell = CreateObject("wscript.Shell") 
    WshShell.Run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16"
End Sub

'*************************************************************************************************************************************************'
'Sub Clear_Saved_Passwords()
'Description: This subrutine deletes the saved passwords of the internet explorer browser
'Date:11/09/2013
'Author: Yon Cuadrado
'*************************************************************************************************************************************************'
Sub Clear_Saved_Passwords()
    Dim WshShell
    Set WshShell = CreateObject("wscript.Shell") 
    WshShell.Run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32"
End Sub

'*************************************************************************************************************************************************'
'Sub Clear_All()
'Description: This subrutine deletes the saved passwords, the form data, the cookies, the history and the temp files  
'             of the internet explorer browser
'Date:11/09/2013
'Author: Yon Cuadrado
'*************************************************************************************************************************************************'
Sub Clear_All()
	Dim WshShell
	Set WshShell = CreateObject("wscript.Shell") 
	WshShell.Run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255",1,True
End Sub

'*************************************************************************************************************************************************'
'Sub Clear_Clear_Add_ons_Settings()
'Description: This subrutine deletes the addon settings of the internet explorer browser
'Date:11/09/2013
'Author: Yon Cuadrado
'*************************************************************************************************************************************************'
Sub Clear_Clear_Add_ons_Settings()
    Dim WshShell
    Set WshShell = CreateObject("wscript.Shell") 
    WshShell.Run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351"
End Sub 

'*************************************************************************************************************************************************'
'Function fCompressFiles(strObject,strFileOrFolder,strCompressedResultsFile)
'Description: This function compresses the files of one folder that is provided as a parameter.
'Date:11/08/2013
'Author: Yon Cuadrado

'Parameters:
'strObject = If it is equal to "FOLDER" the function will compress all the files that are in the directory passed in the 
'            parameter "strFileOrFolder". If if is equal to "FILE" the function will compress the file passed in the 
'            parameter "strFileOrFolder"
'strFileOrFolder = Path and name of the folder or file that is going to be compressed
'strCompressedResultsFile = Path and name of the file with the compressed folder or file that is going to be generated

'Return value
' it doesn't return any value
'*************************************************************************************************************************************************'

Function fCompressFiles(strObject,strFileOrFolder,strCompressedResultsFile)

	Dim oFSO
	Dim sSourceFile

	Set oFSO = CreateObject("Scripting.FileSystemObject")
	Set oApp = CreateObject("Shell.Application")

	If strObject = "FOLDER" Then

		'First delete the zip file				
		' Check if file exists to prevent error
		If oFSO.FileExists(strCompressedResultsFile) Then
			oFSO.DeleteFile strCompressedResultsFile
		End If

		'Create the zip file
		Set oNewZipFile = oFSO.CreateTextFile(strCompressedResultsFile)

		oNewZipFile.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)

		oNewZipFile.Close
		Set oNewZipFSO = Nothing

		'zip the files
		If oFSO.FolderExists(strFileOrFolder) Then
			Set objFolder = oFSO.GetFolder(strFileOrFolder)
			intFileCount = objFolder.Files.Count
		End If

		'Copy the files to the compressed folder

		intZipCurrentNumberOfFiles = oApp.Namespace(strCompressedResultsFile).items.Count 	
		intZipFileExpectedNumberOfFiles = 1

		For Each fileNameInZip In oApp.Namespace((strFileOrFolder)).items

			oApp.Namespace((strCompressedResultsFile)).CopyHere oApp.Namespace((strFileOrFolder)).items.Item(CStr(fileNameInZip))   

			Do While intZipCurrentNumberOfFiles <> intZipFileExpectedNumberOfFiles
				On Error Resume Next
				 intZipCurrentNumberOfFiles = oApp.Namespace(strCompressedResultsFile).items.Count 	
				Wait 2

				 If Err.Number <> 0 Then
					 Wait 2
					 intZipCurrentNumberOfFiles = oApp.Namespace(strCompressedResultsFile).items.Count 	
				 End If	
			Loop

			intZipFileExpectedNumberOfFiles = intZipFileExpectedNumberOfFiles + 1
		Next
		
		ElseIf strObject = "FILE" Then

			'First delete the zip file
			' Check if file exists to prevent error
			If oFSO.FileExists(strCompressedResultsFile) Then
				oFSO.DeleteFile strCompressedResultsFile
			End If

			'Create the zip file
			Set oNewZipFile = oFSO.CreateTextFile(strCompressedResultsFile)

			oNewZipFile.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)

			oNewZipFile.Close
			Set oNewZipFSO = Nothing

			intZipCurrentNumberOfFiles = oApp.Namespace(strCompressedResultsFile).items.Count 	
			intZipFileExpectedNumberOfFiles = 1

			 oApp.Namespace((strCompressedResultsFile)).CopyHere strFileOrFolder   

			Do While intZipCurrentNumberOfFiles <> intZipFileExpectedNumberOfFiles
				On Error Resume Next
				 intZipCurrentNumberOfFiles = oApp.Namespace(strCompressedResultsFile).items.Count 	
				Wait 2

				 If Err.Number <> 0 Then
					 Wait 2
					 intZipCurrentNumberOfFiles = oApp.Namespace(strCompressedResultsFile).items.Count 	
				 End If	
			Loop

		End If   		
		
End Function


'*************************************************************************************************************************************************'
'Function fConvert_data_fromSAPFormat_to_ExcelFormat (ByVal strData, ByVal strDataProfile)
'Description: This function converts data from SAP format to excel format
'Date:11/09/2013
'Author: Yon Cuadrado

'Parameters:
'strData = Value that is going to be converted
'strDataProfile = Current SAP profile Value

'Return value
' the strData value converted to excel format
'*************************************************************************************************************************************************'
Function fConvert_data_fromSAPFormat_to_ExcelFormat (ByVal strData, ByVal strDataProfile)

	intDataLength = Len(strData)
	For i = 1 to intDataLength
		If Mid(strData,i,1) <> "Y" And Mid(strData,i,1) <> "M" And Mid(strData,i,1) <> "D" And Mid(strData,i,1) <> "G" Then
			Exit For
		End If
	Next
	strProfileSeparator = Mid(strData,i,1)

	arrData = Split(strData,strProfileSeparator)
	arrProfileData = Split(strDataProfile,strProfileSeparator)

	For i = 0 to 2
		If arrProfileData(i) = "YYYY" or  dataorderarray(i) = "GYY" Then
			strYear = data_array(i)
		 ElseIf arrProfileData(i) = "MM"  Then
			strMonth = data_array(i)
		 ElseIf arrProfileData(i) = "DD"  Then
			strDay = data_array(i)
		End If
	Next

	fConvert_data_fromSAPFormat_to_ExcelFormat = strMonth &"/" & strDay & "/" & strYear

End Function

'*************************************************************************************************************************************************'
'Function fConvert_data_from_ExcelFormat_to_SAPFormat (ByVal strData, ByVal strDataProfile)
'Description: This function converts data from excel format to SAP format
'Date:11/09/2013
'Author: Yon Cuadrado

'Parameters:
'strData = Value that is going to be converted
'strDataProfile = Current SAP profile Value

'Return value
' the strData value converted to SAP format
'*************************************************************************************************************************************************'
Function fConvert_data_from_ExcelFormat_to_SAPFormat(ByVal strData, ByVal strDataProfile)

	intDataLength = Len(strData)
	For i = 1 to intDataLength
		If Mid(strData,i,1) <> "Y" And Mid(strData,i,1) <> "M" And Mid(strData,i,1) <> "D" And Mid(strData,i,1) <> "G" Then
			Exit For
		End If
	Next
	strProfileSeparator = Mid(strData,i,1)

	arrData = split(strData,"/")
	arrProfileData = Split(strDataProfile,strProfileSeparator)

	For i = 0 to 2
		If arrProfileData(i) = "YYYY" or  arrProfileData(i) = "GYY" Then
		   strDataFinal = strDataFinal & arrData(2) & strProfileSeparator
		 ElseIf arrProfileData(i) = "MM"  Then
		   strDataFinal = strDataFinal & arrData(0)  & strProfileSeparator
		 ElseIf arrProfileData(i) = "DD"  Then
		   strDataFinal = strDataFinal & arrData(1)  & strProfileSeparator
		End If
	Next

	fConvert_data_from_ExcelFormat_to_SAPFormat = Left(strDataFinal,Len(strDataFinal) - 1) 

End Function

'*******************************************************************************************************************************************************************************************
'NAME: ReadFile
'AUTHOR: EHG
'DATE: November 07th, 2007
'Remarks:
'Description:

'*******************************************************************************************************************************************************************************************
'Function fReadFile(ByVal strFileNameAndPath)
'Description: This function reads a text file
'Date:11/09/2013
'Author: Yon Cuadrado

'Parameters:
'strFileNameAndPath = File and path that is going to be read
'*************************************************************************************************************************************************'
Function fReadFile(ByVal strFileNameAndPath)

    Dim fso, v_file
    Const ForReading = 1
    
    Set fso = CreateObject("Scripting.FileSystemObject")

    Set v_file = fso.OpenTextFile(strFileNameAndPath, ForReading, False)
    
    'Skip the file header (12 lines)
    For xx=1 to 12
        v_file.SkipLine
    Next
    var_Jobs=0
    
    'Get the line to get the last number
    Do While v_file.AtEndOfStream <> True
    	var_ReadLineTextFile = v_file.ReadLine
    	'Delete the first and last |
    	var_ReadLineTextFile=Mid(var_ReadLineTextFile,2,Len(var_ReadLineTextFile)-2)
    	'Split the file line
    	var_ReadLineArray = Split(var_ReadLineTextFile, "|")
    	var_Number=Trim(var_ReadLineArray(7))
    	If CInt(var_Number)>10 Then
    		var_Jobs=var_Jobs+1
    	Else
    		Exit Do
    	End If
    Loop

    v_file.close

End Function

'*******************************************************************************************************************************************************************************************
'Function fCloseProcessesByName(ByVal strProcessName)
'Description: This function closes all the open proceses in task manager with the given name
'Date:11/09/2013
'Author: Yon Cuadrado

'Parameters:
'strProcessName = Name of the process that is going to be closed

'*************************************************************************************************************************************************'
Function fCloseProcessesByName(ByVal strProcessName)

    Set process = GetObject("winmgmts:\\")
    Set allProceses = process.ExecQuery("Select * from Win32_Process Where Name = '" & strProcessName & "'")
    For Each process in allProceses
        process.Terminate()
    Next

End Function

'*******************************************************************************************************************************************************************************************
'Function fWaitForProcess(ByVal strProcessName)
'Description: This function waits for a process to appear in the tasks list
'Date:11/09/2013
'Author: Yon Cuadrado

'Parameters:
'strProcessName = Name of the process that is going to be waited for
'intTimeOut = Time in seconds that the function will be waiting for the process to appear

'Return value
' PASSED if the process appears and FALSE otherwise
'*************************************************************************************************************************************************'
Function fWaitForProcess(ByVal strProcessName, ByVal intTimeOut)

    datCurrentTime1 = Now()
    Set process = GetObject("winmgmts:\\")
    Do While  datSpentTime < CInt(intTimeOut)
    	Set allExcel = process.ExecQuery("Select * from Win32_Process Where Name = '" & strProcessName & "'")
    	If  allExcel.Count > 0 Then
    		Exit Do
    	End If
    	datCurrentTime2 = Now()
    	datSpentTime = DateDiff("s",datCurrentTime1,datCurrentTime2)
    Loop
    
    Set allExcel = process.ExecQuery("Select * from Win32_Process Where Name = '" & strProcessName & "'")
	If  allExcel.Count > 0 Then
		fWaitForProcess = "PASSED"
	Else
	    fWaitForProcess = "FAILED"
	End If

End Function

'*******************************************************************************************************************************************************************************************
'Function fSendEmailWithSMPT(ByVal strFrom, ByVal strTo, ByVal strCC, ByVal strSubject, ByVal strBody, ByVal strAttachment)
'Description: This function sends an email using SMTP program
'Date:11/09/2013
'Author: Yon Cuadrado

'Parameters:
'strFrom = sender of the message
'strCC = person in copy of the email
'strSubject = subject of the message
'strBody = body of the message
'strAttachment = attachment of the email

'Return value
' PASSED if the process appears and FALSE otherwise
'*************************************************************************************************************************************************'
Function fSendEmailWithSMPT(ByVal strFrom, ByVal strTo,ByVal strCC, ByVal strSubject, ByVal strBody, ByVal strAttachment)

    Const cdoSendUsingPort = 2
    Const cdoBasic = 1
    Dim objCDOConfig
    Dim objCDOMessage
    Dim strSch

    strSch = "http://schemas.microsoft.com/cdo/configuration/"
    Set objCDOConfig = CreateObject("CDO.Configuration")
    With objCDOConfig.Fields
    .Item(strSch & "sendusing") = cdoSendUsingPort
    .Item(strSch & "smtpserver") = "mtamr1001.accenture.com"
    ' Only used if SMTP server requires Authentication
    '.Item(strSch & "smtpauthenticate") = cdoBasic
    .Update
    End With

    Set objCDOMessage = CreateObject("CDO.Message")
    With objCDOMessage
    Set .Configuration = objCDOConfig

    .From = strFrom
    .Sender = strFrom
    .To = strTo
	.CC = strCC
    .Subject = strSubject
    .TextBody = strBody
	'.AddAttachment Environment("varAttach")

	 On error resume next
    .Send
	If Err.Number <> 0  Then
		fSendEmailWithSMPT = Err.Number

	End If

    End With
    Set objCDOMessage = Nothing
    Set objCDOConfig = Nothing
    
End Function


'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'Function fExecuteAction(strWindowName,strAction)
'Descripcion: This function Navigates to the window where the control is located

'Parameters: 
'strControlName = Name of the control
'strWindowName = Name of the window where the control is located
'strActionListString = String with the list of the actions that are going to be performed to get to the object
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Function fExecuteAction(ByVal strWindowName,ByVal strSubWindowName,ByVal strActionListString) '(strControlType,strControlName,strWindowName,srSubWindowName

	fExecuteAction = "FAILED"
	On Error Resume Next

	arrPantalla = Split(Datatable("Pantalla_IN", strTab), "-")
	arrControl = Split(Datatable("Nombre_Control_IN",strTab),"-")	

	strActionListString = Replace(strActionListString,Chr(10),"")
	arrActionList = Split(strActionListString,";")

	If UBound(arrActionList) = 0 Then
		fExecuteAction = "PASSED"
		Exit Function
	End If

	intActionArrayIndex = 0
	Do

		arrActionNameTemp1 = arrActionList(intActionArrayIndex)
		arrActionNameTemp1 = Replace(arrActionNameTemp1,"–","-")
		arrActionNameTemp = Split(arrActionNameTemp1 ,"-")

		If IsEmpty(arrActionNameTemp(0)) Then
			strAction = ""
		Else
			strAction = arrActionNameTemp(0)
		End If
		

		'Action Types
	
		' 1 -  Fill a control

		If InStr(1,LCase(strAction),"cuadro de texto") <> 0 Then
		
			strControlType  = Trim(arrActionNameTemp(0))
			strControlValueTemp = Split(Trim(arrActionNameTemp(1)),"=")
			strControlName = Trim(strControlValueTemp(0))
			strControlValue = Trim(strControlValueTemp(1))
			
			strPaintInControl = fCompleteControl(strWindowName,srSubWindowName,strControlType,strControlName,objObject,Trim(strControlValue),strTab)
	
			If strPaintInControl <> "PASSED" Then
			
					If strPaintInControl <> ""  Then
						fExecuteAction = strPaintInControl
					Else
						fExecuteAction = "Ha habido un problema al intentar pintar en el campo "  & strControlType & " " & strControlName
					End If

					Exit Function

			End If

			ElseIf InStr(1,LCase(strAction),"desplegable") <> 0 Then
			
				strControlType  = Trim(arrActionNameTemp(0))
				strControlValueTemp = Split(Trim(arrActionNameTemp(1)),"=")
				strControlName = Trim(strControlValueTemp(0))
				strControlValue = Trim(strControlValueTemp(1))
				
				strPaintInControl = fCompleteControl(strWindowName,srSubWindowName,strControlType,strControlName,objObject,Trim(strControlValue),strTab)
		
				If strPaintInControl <> "PASSED" Then
					
					If strPaintInControl <> ""  Then
						fExecuteAction = strPaintInControl
					Else
						fExecuteAction = "Ha habido un problema al intentar pintar en el campo "  & strControlType & " " & strControlName
					End If
					
					Exit Function
						
				End If
				
			ElseIf InStr(1,LCase(strAction),"checkbox") <> 0 Then

				strControlType  = Trim(arrActionNameTemp(0))
				strControlValueTemp = Split(Trim(arrActionNameTemp(1)),"=")
				strControlName = Trim(strControlValueTemp(0))
				strControlValue = Trim(strControlValueTemp(1))
				
				strPaintInControl = fCompleteControl(strWindowName,srSubWindowName,strControlType,strControlName,objObject,Trim(strControlValue),strTab)
		
				If strPaintInControl <> "PASSED" Then
				
					If strPaintInControl <> ""  Then
						fExecuteAction = strPaintInControl
					Else
						fExecuteAction = "Ha habido un problema al intentar pintar en el campo "  & strControlType & " " & strControlName
					End If

					Exit Function
						
				End If

			ElseIf InStr(1,LCase(strAction),"radiobutton") <> 0 Then
			
				strControlType  = Trim(arrActionNameTemp(0))
				strControlValueTemp = Split(Trim(arrActionNameTemp(1)),"=")
				strControlName = Trim(strControlValueTemp(0))
				strControlValue = Trim(strControlValueTemp(1))
				
				strPaintInControl = fCompleteControl(strWindowName,srSubWindowName,strControlType,strControlName,objObject,Trim(strControlValue),strTab)
		
				If strPaintInControl <> "PASSED" Then
				
					If strPaintInControl <> ""  Then
						fExecuteAction = strPaintInControl
					Else
						fExecuteAction = "Ha habido un problema al intentar pintar en el campo "  & strControlType & " " & strControlName
					End If

					Exit Function
						
				End If

			ElseIf InStr(1,LCase(strAction),"seleccionar primera linea tabla") <> 0 Then

				strControlType  = "tabla"
				strControlName = arrActionNameTemp(1)
				
				strPaintInControl = fCompleteControl(strWindowName,srSubWindowName,strControlType,strControlName,objObject,Trim(strControlValue),strTab)
		
				If strPaintInControl <> "PASSED" Then
				
					If strPaintInControl <> ""  Then
						fExecuteAction = strPaintInControl
					Else
						fExecuteAction = "Ha habido un problema al seleccionar la fila en la tabla "  & strControlType & " " & strControlName
					End If

					Exit Function
						
				End If				
					
			' 2 -  Click on a control

			ElseIf InStr(1,LCase(strAction),"click") <> 0 Then
			
					intControlTypeEndCharacter = InStr(7,LCase(strAction)," ")
					strControlType = Mid(LCase(strAction),7,intControlTypeEndCharacter- 7)
					intControlNameEndCharacter = InStr(7,LCase(strAction)," – ")
					intControlNameEnd = Cint(InStr(7,LCase(strAction)," – ") - 1)
					strControlName = Mid(LCase(strAction),intControlTypeEndCharacter + 1,Len(strAction)  - intControlTypeEndCharacter )

					strControlCheck = fCheckControl(strWindowName,strSubWindowName,strControlType,strControlName,"","","",strTab)
					
					If strControlCheck <> "PASSED" Then
						fExecuteAction = strControlCheck
						Exit Function
					End If

					Set objObjectToBeUsed = fGetControlObject(strWindowName,srSubWindowName,strControlType,strControlName, strTab)
					objObjectToBeUsed.Click

					If Err.Number <> 0 Then
					
							fExecuteAction = "Ha habido un problema al hacer click en el control  "  & strControlType  & " " & strControlName
							Exit Function
							
					End If

					Browser("Browser").Page("Page").Sync
					strClosePopupResult = fClosePopupIEWindow()
					
					If strClosePopupResult <> "PASSED" Then
						fExecuteAction = "Ha habido un problema al hacer click en el control  y ha aparecido un popup de error"
						Exit Function
					End If
					
					Browser("Browser").Page("Page").Sync
					strClosePopupResult = fClosePopupIEWindow()
					
					If strClosePopupResult <> "PASSED" Then
						fExecuteAction = "Ha habido un problema al hacer click en el control  y ha aparecido un popup de error"
						Exit Function
					End If
					
			ElseIf InStr(1,arrActionNameTemp1,"Carga Inicial de pantalla") = 0 And arrActionNameTemp1 <> "" Then
		
					fExecuteAction = "La siguiente acción no se ha podido ejecutar; " & arrActionNameTemp1
					Exit Function

			End If

				'Hacer click boton - Ocultar Controles
			'3 - Seleccionar primera linea datatable
				'Seleccionar primera linea - datatable

			intActionArrayIndex = intActionArrayIndex + 1

	Loop While intActionArrayIndex <= UBound(arrActionList)

	fExecuteAction = "PASSED"

End Function