macros en excel , ayudar a mejorar tiempos
Publicado por Nicolas (4 intervenciones) el 17/02/2014 21:26:13
chicos me darian una mano viendo en que puedo mejorar mi macro en cuanto a tiempos , esta es la macro . De antemano muchas gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Private Sub WorkBook_Open()
Application.OnTime Now() + TimeValue("00:00:05"), "esta"
End Sub
Sub esta()
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = False
End Sub
Public Function f_EquipoResponde(str_Equipo As String) As String
Dim obj_Shell As Object
Dim obj_FileSystem As Object
Dim obj_Fichero As Object
Dim str_ContenidoFichero As String
Dim str_FicheroTemporal As String
Dim str_NombreMaquina As String
Set obj_Shell = CreateObject("WScript.Shell")
Set obj_FileSystem = CreateObject("Scripting.FileSystemObject")
str_FicheroTemporal = ThisWorkbook.Path & "\temp.txt"
obj_Shell.Run "cmd /c ping -a -n 2 -w 150 " & str_Equipo & " > """ & _
str_FicheroTemporal & """", 0, True
Set obj_Fichero = obj_FileSystem.OpenTextFile(str_FicheroTemporal, 1, False)
str_ContenidoFichero = obj_Fichero.ReadAll
obj_Fichero.Close
Set obj_Fichero = Nothing
obj_FileSystem.DeleteFile (str_FicheroTemporal)
Set obj_FileSystem = Nothing
Set obj_Shell = Nothing
Dim nombre As String
nombre = Mid(Replace(str_ContenidoFichero, vbCrLf, ""), 17, 10)
If InStr(str_ContenidoFichero, "perdidos = 0") > 0 Then
f_EquipoResponde = nombre & " ha RECIBIDOS 100%"
End If
If InStr(str_ContenidoFichero, "perdidos = 1") > 0 Then
f_EquipoResponde = nombre & "ha RECIBIDOS 50%"
End If
If InStr(str_ContenidoFichero, "perdidos = 2") > 0 Then
f_EquipoResponde = "IP VACANTE"
End If
End Function
Valora esta pregunta


0