tag:blogger.com,1999:blog-10912393176081279592024-03-19T03:06:58.699-07:00VB para Aplicaciones (Excel)Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.comBlogger48125tag:blogger.com,1999:blog-1091239317608127959.post-64329148502595988042013-01-20T11:38:00.000-08:002013-01-20T11:42:28.495-08:00ELIMINAR LA PROTECCION EN LIBROS Y HOJASSé que existen miles de publicaciones al respecto pero
siempre viene bien tenerlas a mano y entender cómo funciona.<br />
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
Estos dos procedimientos son muy útiles cuando recibimos
algún archivo protegido, y no nos comunican la contraseña para poder abrirlo.
Sea como fuere, olvido o necesidad, cualquier problema de este tipo podemos
solucionarlo gracias a estos dos procedimientos;<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Para quitar la protección a un libro utilizaremos este
procedimiento:<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Sub DesprotegerLibro()<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">If MsgBox("Realmente desea desproteger el libro actual?", _<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">vbCritical + vbYesNo + vbDefaultButton2, "DesprotegerLibro") =
vbYes Then<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Dim i As Integer, j As Integer, k As Integer<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Dim l As Integer, m As Integer, n As Integer<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">On Error Resume Next<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">For i = 65 To 66: For j = 65 To 66: For k = 65 To 66<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">ActiveWorkbook.Unprotect Chr(i) & Chr(j) & Chr(k) & Chr(l)
& Chr(m) & _<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Chr(i1) & Chr(i2) & Chr(i3) & Chr(i4) & Chr(i5) &
Chr(i6) & Chr(n)<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">If ActiveWorkbook.ProtectStructure = False And
ActiveWorkbook.ProtectWindows = False Then<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">MsgBox "El libro está ahora desprotegido", vbInformation +
vbOKOnly, "DesprotegerLibro"<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Exit Sub<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">End If<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Next: Next: Next: Next: Next: Next<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Next: Next: Next: Next: Next: Next<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">End If<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">End Sub<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal">
Para quietar la protección
a una hoja utilizaremos este otro procedimiento:<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Sub Quitar_contraseña()<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Dim a As Integer, b As Integer, c As Integer<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Dim d As Integer, e As Integer, f As Integer<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Dim a1 As Integer, a2 As Integer, a3 As Integer<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Dim a4 As Integer, a5 As Integer, a6 As Integer<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">On Error Resume Next<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">For a = 65 To 66: For b = 65 To 66: For c = 65 To 66<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">For d = 65 To 66: For e = 65 To 66: For a1 = 65 To 66<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">For a2 = 65 To 66: For a3 = 65 To 66: For a4 = 65 To 66<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">For a5 = 65 To 66: For a6 = 65 To 66: For f = 32 To 126<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Contraseña = Chr(a) & Chr(b) & Chr(c) & Chr(d) & Chr(e)
& Chr(a1) _<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">& Chr(a2) & Chr(a3) & Chr(a4) & Chr(a5) & Chr(a6) &
Chr(f)<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">ActiveSheet.Unprotect Contraseña<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">If ActiveSheet.ProtectContents = False Then<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">MsgBox "¡Enorabuena!" & vbCr & "Se ha quitado la
contraseña:" & vbCr & Contraseña<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Exit Sub<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">End If<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Next: Next: Next: Next: Next: Next<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">Next: Next: Next: Next: Next: Next<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">End Sub<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
La única diferencia
existente entre los dos procedimientos es la utilización del método<b><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;"> Unprotect </span></b>en
los diferentes objetos;<o:p></o:p></div>
<div class="MsoNormal" style="margin: 1.5pt 0.75pt;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">ActiveSheet.<b>Unprotect </b></span>para
desactivar la hoja.<b><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;"><o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin: 1.5pt 0.75pt;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;">ActiveWorkbook.<b>Unprotect </b></span>para
desactivar el libro.<span style="font-family: "Courier New"; font-size: 9.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 1.5pt 0.75pt;">
<br /></div>
<div class="MsoNormal">
Este método no tiene efecto si la hoja o el libro no están
protegidos.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-52407450360601749612013-01-06T13:27:00.001-08:002013-01-06T13:53:03.831-08:00CLASES<br />
<div class="MsoNormal">
<span lang="ES" style="color: #1c2a47; font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: ES; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">En VBA una clase es algo tan sencillo como un procedimiento, que contiene
datos para manejarlos, y con el que se puede crear objetos.<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="ES" style="color: #1c2a47; font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: ES; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Para crear una clase primero debemos crearnos un módulo de clase, desde
el menú insertar seleccionamos la opción Modulo de clase.<o:p></o:p></span><br />
<span lang="ES" style="color: #1c2a47; font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: ES; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"><br /></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="ES" style="color: #1c2a47; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-ansi-language: ES; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Los
módulos de clase presentan dos eventos:</span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 15.0pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<br />
<ul>
<li><b style="color: #1c2a47; font-family: Arial, sans-serif; font-size: 10pt; line-height: 15pt; text-indent: -18pt;">Initialize</b><span style="color: #1c2a47; font-family: Arial, sans-serif; font-size: 10pt; line-height: 15pt; text-indent: -18pt;">: ocurre cuando se crea una instancia de
una clase. Se usa, generalmente para inicializar cualquier dato usado por la
instancia de una clase en el código.</span></li>
<li><b style="color: #1c2a47; font-family: Arial, sans-serif; font-size: 10pt; line-height: 15pt; text-indent: -18pt;">Terminate</b><span style="color: #1c2a47; font-family: Arial, sans-serif; font-size: 10pt; line-height: 15pt; text-indent: -18pt;">: ocurre cuando toda referencia a una
instancia de una clase son removidas de memoria al establecer todas las
variables que la refieren a un objeto a Nothing o cuando la última referencia
al el objeto se encuentra fuera de alcance.</span></li>
</ul>
</div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="ES" style="color: #1c2a47; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-ansi-language: ES; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">En
el siguiente ejemplo creamos un <b><i>módulo
de clase</i></b> donde declaramos públicamente las variables que utilizaremos en
un módulo diferente y crearemos una función que nos devolverá en un mensaje el
nombre completo de un supuesto empleado que estamos dando de alta.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="ES" style="color: #1c2a47; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-ansi-language: ES; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Código
del Módulo de Clase:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
</div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Option Explicit<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Public Nombre As String<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Public Apellido1 As
String<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Public Apellido2 As
String<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Public Direccion As
String<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Public Provincia As
String<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Public Function
NombreCompleto() As String<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">NombreCompleto =
Apellido1 & " " & Apellido2 & " " & Nombre<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">End Function<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="ES" style="color: #1c2a47; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-ansi-language: ES; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Código
del Módulo:<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Sub prueba_clase()<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Dim empleado As New
Clase1<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> With empleado<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> .Nombre = InputBox("Nombre:
")<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> .Apellido1 = InputBox("Primer
Apellido: ")<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> .Apellido2 = InputBox("Segundo
Apellido: ")<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> .Direccion = InputBox("Dirección: ")<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> .Provincia = InputBox("Provincia:
")<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> MsgBox "Empleado: " &
.NombreCompleto<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> End With<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">End Sub<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<br /></div>
<br />
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="ES" style="color: #1c2a47; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-ansi-language: ES; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Al
utilizar <b>New</b> en la variable <i>empleado</i>
se crea una nueva instancia del objeto como primera referencia, de forma que no
tenemos que utilizar la instrucción <b>Set</b> para asignar la referencia del
objeto.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMUAWtMHUPsm5i33b1RxERsVmkBfZEBqaej7vdws0QYA9nMSbcTptRFMyFVgJyK9zD4v4O8Rui4vfjRI2SS8k1TzrY8Uz1gQ6TLQqASrkoiA8YzmJfGgDCqSBL0t-d8JcNEgqUSDMQ1egy/s1600/Dibujo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="253" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMUAWtMHUPsm5i33b1RxERsVmkBfZEBqaej7vdws0QYA9nMSbcTptRFMyFVgJyK9zD4v4O8Rui4vfjRI2SS8k1TzrY8Uz1gQ6TLQqASrkoiA8YzmJfGgDCqSBL0t-d8JcNEgqUSDMQ1egy/s400/Dibujo.jpg" width="400" /></a></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="ES" style="color: #1c2a47; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-ansi-language: ES; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Como
vemos en la imagen la variable <i>empleado</i>
nos muestra todas las propiedades y métodos creados en el módulo de clase.<o:p></o:p></span><br />
<span lang="ES" style="color: #1c2a47; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-ansi-language: ES; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"><br /></span></div>
Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-63394372903764499492013-01-01T06:13:00.001-08:002013-01-01T06:17:53.731-08:00ESTADÍSTICA DEL BLOG 2012<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Zs6OmmYncoJcz5jGp4MHdjgWuKQb1IMe73mIkF6Ozn8QhASBU5UGov_LNBTmCjwsitMvG_JvloTEG8s7WrGKnysBeTKxz4-gzo4nWMQvi2IH4w_Imlhikx5aHqr-jXT7B2k5OPiZ-GeT/s1600/VISI.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="344" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Zs6OmmYncoJcz5jGp4MHdjgWuKQb1IMe73mIkF6Ozn8QhASBU5UGov_LNBTmCjwsitMvG_JvloTEG8s7WrGKnysBeTKxz4-gzo4nWMQvi2IH4w_Imlhikx5aHqr-jXT7B2k5OPiZ-GeT/s640/VISI.JPG" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDUWVoXElXd_jP4UFq-VHby6Qi67VJ2w8GHgCN9-IT5mWMpyCQ_pFICyVzyZkA9LJRwny7rCCKPMepO9zq4NoKA2w0CItXCLkZDzx3ozOw7FVzwH2o9TsKHd5lxQyhkHlCOfmpEBTQx8e2/s1600/vISITAS.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="395" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDUWVoXElXd_jP4UFq-VHby6Qi67VJ2w8GHgCN9-IT5mWMpyCQ_pFICyVzyZkA9LJRwny7rCCKPMepO9zq4NoKA2w0CItXCLkZDzx3ozOw7FVzwH2o9TsKHd5lxQyhkHlCOfmpEBTQx8e2/s640/vISITAS.JPG" width="640" /></a></div>
<br />Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-67762967009227881742013-01-01T05:34:00.000-08:002013-01-01T06:08:17.067-08:00CreateObject<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; color: #333333; font-family: "Arial","sans-serif"; font-size: 10pt;">Como ya
sabemos por anteriores post (</span><span style="font-family: Arial, sans-serif; font-size: 10pt;"><a href="http://vbaparaaplicacionesexcel.blogspot.com/2012/01/comunicacion-con-outlook.html" target="_blank"><span style="color: #333333;">Comunicación
con Outlook</span></a></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; color: #333333; font-family: "Arial","sans-serif"; font-size: 10pt;"> y </span><span style="font-family: Arial, sans-serif; font-size: 10pt;"><a href="http://vbaparaaplicacionesexcel.blogspot.com/2012/06/comprimir-archivos.html" target="_blank"><span style="color: #333333;">COMPRIMIR
ARCHIVOS</span></a></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; color: #333333; font-family: "Arial","sans-serif"; font-size: 10pt;">) la función <b>CreateObject </b>nos
sirve para crear </span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; color: #222222; font-family: "Arial","sans-serif"; font-size: 10pt;">y devolver una referencia a un objeto </span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; color: #333333; font-family: "Arial","sans-serif"; font-size: 10pt;">ActiveX.</span><br />
<div style="margin: 0cm 0cm 0.0001pt;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="background: white; color: #333333; font-family: "Arial","sans-serif"; font-size: 10.0pt;">En este caso
utilizaremos esta función para abrir Internet Explorer e ir a la dirección que
le indiquemos.</span><span style="font-family: Arial, sans-serif; font-size: 10pt;"><o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="background: white; color: #333333; font-family: "Arial","sans-serif"; font-size: 10.0pt;">Asignamos el
objeto (Internet Explorer) a una variable de objeto.</span><span style="font-family: Arial, sans-serif; font-size: 10pt;"><o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="background: white; color: #333333; font-family: "Arial","sans-serif"; font-size: 10.0pt;">Utilizamos la
referencia <b>ExApp</b> para tener acceso a la propiedad <b>Visible</b> de
Internet Explorer y después utilizamos el método <b>Navigate</b> para
ir a la dirección indicada por nosotros. Finalmente se libera la referencia.</span><br />
<span style="background: white; color: #333333; font-family: "Arial","sans-serif"; font-size: 10.0pt;"><br /></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br />
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Sub GetInternetExplorer()<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Dim ExApp As Object<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">On Error
GoTo Error<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Set ExApp =
CreateObject("InternetExplorer.Application")<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">
With ExApp<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">
.Visible = True<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">
End With<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">
With ExApp<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">
.Navigate URL:="http://vbaparaaplicacionesexcel.blogspot.com.es/"<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">
End With <o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Error:<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Set ExApp =
Nothing<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">On Error
GoTo 0<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div class="MsoNormal" style="background-color: white; background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<u2:p></u2:p><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">End Sub<o:p></o:p></span></div>
<br />
<span style="background: white; color: #333333; font-family: "Arial","sans-serif"; font-size: 11.0pt;"></span><br />
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; line-height: 15pt; margin-bottom: 0.0001pt;">
<span style="background: white; color: #333333; font-family: "Arial","sans-serif"; font-size: 11.0pt;"><span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"><br /></span></span></div>
<span style="background: white; color: #333333; font-family: "Arial","sans-serif"; font-size: 11.0pt;">
</span></div>
Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-26387855104593805912012-12-30T11:01:00.001-08:002012-12-31T06:18:24.922-08:00COLECCIONES<span style="background-color: white; font-family: Arial, sans-serif; font-size: 10pt; line-height: 150%;">¿Qué es una colección?</span><br />
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Una colección es un objeto utilizado para agrupar
y administrar objetos relacionados. Las colecciones son un buen método para
hacer un seguimiento de los objetos que una aplicación puede necesitar crear o
destruir dinámicamente.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Una colección se parece a una matriz, en el
sentido que podemos acceder a sus elementos mediante un índice.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Ventajas de utilizar colecciones frente a las
matrices:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
</div>
<ul>
<li><span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 150%;">Utilizan menos memoria.</span></li>
<li><span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 150%;">El acceso a los elementos de la colección es mas
flexibe.</span></li>
<li><span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 150%;">Las colecciones tienen métodos para añadir nuevos
elementos y eliminar otros.</span></li>
<li><span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 150%;">El tamaño de la colección se ajusta
automáticamente.</span></li>
<li><span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 150%;">Pueden tener simultáneamente elementos de
diferentes tipos.</span></li>
</ul>
<br />
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">La palabra clave <b>New</b> en la declaración de la
variable produce un objeto Collection que se va a crear cuando el control pasa
a la instrucción de declaración.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"><br /></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 13px; line-height: 20px;">Dim loteria As New Collection</span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 13px; line-height: 20px;"><br /></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">El objeto Collection tiene los siguientes
métodos:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
</div>
<ul>
<li><span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 150%;"><b>Add</b>: Agrega un elemento a un objeto Collection de
VBA.</span></li>
<li><span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 150%;"><b>Remove</b>: Quita un elemento de un objeto Collection
de VBA.</span></li>
</ul>
<br />
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Y las siguientes propiedades:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
</div>
<ul>
<li><span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 150%;"><b>Count</b>: Devuelve un valor Integer que contiene el
número de elementos en una colección.</span></li>
<li><span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 150%;"><b>Item</b>: Devuelve un elemento concreto de un objeto
Collection de VBA por posición o por clave.</span></li>
</ul>
<br />
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">El siguiente procedimiento creamos la colección
lotería con cinco elementos (números
aleatorios de 0 a 9) que presentamos concatenados dentro de una variable
string en un mensaje.<o:p></o:p></span></div>
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Sub loteriaNiño()<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Dim loteria As New
Collection<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Dim numero As Integer, n
As Integer<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">' Llenamos el objeto
colección de números enteros aleatorios.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> For n = 1 To 5<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> numero = Int(rnd * 9)<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> loteria.Add numero<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> Next n<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">' Recorremos el objeto de
colección para presentar el numero.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Dim premio As String<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> For n = 1 To loteria.Count<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> premio = premio & loteria.Item(n)<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> Next n<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">MsgBox "El numero
premiado es... " & Chr(13) & premio<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">End Sub<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"><br /></span></div>
Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-62860795186086557382012-12-16T03:29:00.000-08:002012-12-30T11:04:31.216-08:00DATOS DUPLICADOSEn esta
publicación vamos a explicar cómo podemos eliminar la fila donde nos
encontramos dos datos iguales, es decir, tenemos por ejemplo en la columna
"A" referencias de nuestros productos y en la columna "D"
tenemos referencias del proveedor, se nos da el caso de que alguna de las
referencias son coincidentes y las necesitamos eliminar.<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<o:p></o:p></div>
<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYsrQQbys5yGH76aGujUojGhykRNZEbt7HSggoQjTmMyjPmNiK5Zdpy13bqkFRajzPY1gQA3NQnKTtX449xA-Co9-PnhVmdI82Q7c5zophk7u4juXr2gA7sijrxMJOhoaLVOtR_HhHsArn/s1600/Dibujo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYsrQQbys5yGH76aGujUojGhykRNZEbt7HSggoQjTmMyjPmNiK5Zdpy13bqkFRajzPY1gQA3NQnKTtX449xA-Co9-PnhVmdI82Q7c5zophk7u4juXr2gA7sijrxMJOhoaLVOtR_HhHsArn/s320/Dibujo.jpg" width="303" /></a></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
Al mismo
tiempo vamos a provechar y vamos a incluir la aplicación <b><i><u>StatusBar</u></i></b> para
ver la evolución de nuestro procedimiento.<o:p></o:p></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIXcPCw0ZdEcVQBq2QK2tdeLQgrF-j4cyv9V_OSJRB24XLT8t096Le-BQUf0sg8ouFuf3aCz3QAlBzees_ikwUCEPY-pWOZ7xFwFt_k_bnJSvutwlsbQgIrsKuH7mrcPxEoBMLe36Ubjb8/s1600/Captura1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIXcPCw0ZdEcVQBq2QK2tdeLQgrF-j4cyv9V_OSJRB24XLT8t096Le-BQUf0sg8ouFuf3aCz3QAlBzees_ikwUCEPY-pWOZ7xFwFt_k_bnJSvutwlsbQgIrsKuH7mrcPxEoBMLe36Ubjb8/s1600/Captura1.JPG" /></a></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"><br /></span>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">Option Explicit<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">Sub EliminarFilas() <o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">Dim Rango As Range, Fila As Long,
ÚltimaFila As Long <o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">Application.ScreenUpdating = False<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">Range("A1").Select<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">ÚltimaFila =
Range("A:A").End(xlDown).Row <o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">For Fila = 1 To ÚltimaFila<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">
Application.StatusBar = "Procesando fila " & Fila & " /
" & ÚltimaFila<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;"> </span><span style="font-family: "Courier New"; font-size: 10.0pt;"> <span style="color: #000066;">If Range("A" & Fila).Value =
Range("D" & Fila).Value Then<o:p></o:p></span></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">
If Rango Is Nothing = True Then<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">
Set Rango = Rows(Fila)<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">
Else<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">
Set Rango = Application.Union(Rango, Rows(Fila))<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">
End If<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;"> End If<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">Next Fila<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">If Rango Is Nothing = False Then<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;"> Rango.Select<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;"> Selection.Delete<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;"> Range(1, 1).Select<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">End If <o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">Application.StatusBar = "Proceso
finalizado"<o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">Application.ScreenUpdating = True<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt;">End Sub<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
</div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; line-height: 115%;"><br /></span>
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"><br /></span></div>
Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-72147457772275325182012-06-10T12:18:00.001-07:002012-06-10T12:23:15.994-07:00COMPRIMIR ARCHIVOS<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Los archivos en formato ZIP probablemente sean los tipos
de archivos mas utilizados, este ejemplo muestra como crear un archivo ZIP de
un grupo de archivos seleccionados por el usuario con el método (</span><b style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Application.GetOpenFilename</b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">).
Después crea un archivo llamado </span><i style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><u>PruebaComprimir.zip</u></i><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">
en el directorio donde este guardado el Excel que contenga el siguiente
procedimiento.</span><br />
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub ComprimirArchivos()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Dim
ShellApp As Object<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Dim
FileNameZip As Variant<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Dim
FileNames As Variant<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Dim i
As Long, FileCount As Long<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">' Obtener los nombres de los archivo<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">FileNames =
Application.GetOpenFilename _<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">(FileFilter:="Todos
los archivos. (*.*),*.*", _<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> FilterIndex:=1, _<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Title:="</span> <span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Seleccione los
archivos para comprimir. ", _<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> MultiSelect:=True)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">' Salir si se cancela el cuadro de diálog</span><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">o<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> If Not
IsArray(FileNames) Then Exit Sub<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">
FileCount = UBound(FileNames)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">
FileNameZip = Application.DefaultFilePath & "\PruebaComprimir.zip"<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <o:p></o:p></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmdT920l5gERMlo7qLWNqq_ivj3w2-c3yFkDHLUXpXmwiA59ZI335f_dfNRNNVUE0W6rM89V_HFOA74MWwMRqq13jKueEJvFkai0gM3LbPFluj6TLrVUInyAdnCV7gWYqwJ1TEhXEgETzT/s1600/Captura.JPG" imageanchor="1" style="font-family: 'Times New Roman'; font-size: medium; line-height: normal; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="324" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmdT920l5gERMlo7qLWNqq_ivj3w2-c3yFkDHLUXpXmwiA59ZI335f_dfNRNNVUE0W6rM89V_HFOA74MWwMRqq13jKueEJvFkai0gM3LbPFluj6TLrVUInyAdnCV7gWYqwJ1TEhXEgETzT/s400/Captura.JPG" width="400" /></a></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">
</span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">' Crear
archivo Zip vacío...</span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Open
FileNameZip For Output As #1<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Print
#1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Close
#1<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Set
ShellApp = CreateObject("Shell.Application")<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">' Copia los archivos a la carpeta comprimida<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">For i =
LBound(FileNames) To UBound(FileNames)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">
ShellApp.Namespace(FileNameZip).CopyHere FileNames(i)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Next i<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> On
Error Resume Next<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Do
Until ShellApp.Namespace(FileNameZip).items.Count = FileCount<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">
Application.Wait (Now + TimeValue("0:00:01"))<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Loop<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> If MsgBox(FileCount & " Los archivos
se han comprimido en:" & _<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">vbNewLine & FileNameZip & vbNewLine & vbNewLine & _<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> "</span> <span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Quieres ver el archivo zip?",
vbQuestion + vbYesNo) = vbYes Then _<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Shell "Explorer.exe /e," & FileNameZip, vbNormalFocus<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicazuPNaBieVud_HJ-Nqt-XRRYBJXrVIOgiJEq4xQ7fPwoE47UpJxtW4QDIefvafEWEfIr3muhIyz0FU4coSjeDlLqeGkZ3kpbmYthTRvUgXV2oRi8oN9-WVZjjdapfj6lAamE_WcCVe_b/s1600/Captura2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="155" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicazuPNaBieVud_HJ-Nqt-XRRYBJXrVIOgiJEq4xQ7fPwoE47UpJxtW4QDIefvafEWEfIr3muhIyz0FU4coSjeDlLqeGkZ3kpbmYthTRvUgXV2oRi8oN9-WVZjjdapfj6lAamE_WcCVe_b/s320/Captura2.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br /></span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-76830066790958082982012-04-29T04:55:00.001-07:002012-04-29T04:56:52.298-07:00EL protocolo DDE<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El protocolo de intercambio dinámico de datos DDE
(Dynamic Data Exchange) es uno de los métodos de comunicación entre procesos
que permite intercambiar datos entre aplicaciones de Windows. El protocolo DDE
está basado en el sistema de mensajería construido por Windows.</span><br />
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">EL vínculo DDE comprende tres fases principales:<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">1º.- Inicialización: la aplicación destino busca la
aplicación fuente y establece con ella un canal de comunicación (vinculo).<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función <b>DDEinitiate</b>: Permite inicia la
comunicación entre dos aplicaciones.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">2º.- Conversación: se intercambian los datos en el
canal.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función <b>DDE</b>: Permite establecer la conversación.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función <b>DDESend</b>: Envía un elemento de información
a la aplicación.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función <b>DDEPoke</b>: Envía información a la
aplicación fuente por un canal abierto.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función <b>DDERequest</b>: pide información a la
aplicación fuente.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función <b>DDEExcute</b>: envía una cadena de comandos a
la aplicación vinculada.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">3º.- Clausura: cierra el canal de comunicación.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función <b>DDETerminate</b>: cierra el canal de
información DDE.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función <b>DDETerminateAll</b>: cierra todos los canales
de comunicación DDE.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El siguiente ejemplo muestra como copiar celdas
Excel al principio de un documento Word.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Sub transferirInforme()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Dim canal As Long<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">'Inicializacion<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> canal =
Application.DDEInitiate("WinWord", "C:\Users\Jose
Luis\Desktop\PruebaDDE\presupuesto.docx")<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">
Worksheets(1).Range("D8:E12").Select<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">'Conversacion<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">
Application.DDEPoke canal, "\StartOfDoc", Selection<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">'Clausura<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">
Application.DDETerminate canal<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">End Sub<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">“\ StartOfDoc” es un
marcador predefinido en Word.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br /></span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-32398561572578611352012-04-22T15:39:00.001-07:002012-04-22T15:47:17.917-07:00Invalidar la X del UserForm<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Alguna vez nos hemos preguntado como podría impedir
que el usuario pulse el botón de cerrar el formulario. <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Para eliminar el botón de cerrar de una barra de
titulo de un UserForm, se necesita complejas funciones API como las que vimos en el post anterior. Una solución mucho mas sencilla consiste en interceptar todos
los intentos de cerrar el UserForm por medio de un procedimiento de eventos “<i>UserForm_QueryClose</i>” en el modulo de código
del UserForm.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El siguiente
ejemplo impide al usuario cerrar el formulario pulsando el botón de Cerrar:</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Private Sub UserForm_QueryClose(Cancel As
Integer, CloseMode As Integer)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> If
CloseMode = vbFormControlMenu Then<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">
Cancel = True<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End If<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Cuando se intenta cerrar el formulario, utilizamos
el procedimiento de evento QueryClose para establecer la propiedad Cancel a True,
deteniendo el proceso de cierre.<o:p></o:p></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br /></span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-4750937868904968052012-04-08T01:03:00.003-07:002012-04-08T01:27:57.356-07:00Truco para UserForm<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Excel no ofrece de ninguna manera mostrar directamente un formulario sin su barra de titulo, pero esto lo podemos hacer realidad gracias a la utilización de funciones API.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Que es API??<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">API es un acrónimo de <b><u>I</u></b>nterfaz de <b><u>p</u></b>rogramación de <b><u>a</u></b>plicaciones, el conjunto de comandos que utiliza una aplicación para solicitar y realizar servicios de nivel inferior del sistema operativo del PC.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Cuando necesites capacidades que vayan más allá del lenguaje y los controles comunes proporcionados por Microsoft Visual Basic, puedes llamar directamente a los procedimientos incluidos en las bibliotecas de vínculos dinámicos (DLL, Dinamyc Link Libraries). Al llamar a estos procedimientos, podrás tener acceso a los miles de procedimientos que constituyen la espina dorsal del sistema operativo Microsoft Windows, así como a rutinas creadas en otros lenguajes.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Para mostrar un UserForm sin barra de titulo necesitamos cuatro funciones API:</span></div><div class="MsoNormal"></div><div class="MsoNormal"></div><ul><li><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Function GetWindowLong</span></li>
<li><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Function SetWindowLong</span></li>
<li><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Function DrawMenuBar</span></li>
<li><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Function FindWindowA </span></li>
</ul><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Que declararemos de forma Privada dentro de nuestro formulario, luego las haremos llamar desde el procedimiento de iniciación del formulario (</span><i><span style="font-family: 'Times New Roman', serif; line-height: 115%;">UserForm_Initialize</span></i><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">).<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El código quedaría más o menos de la siguiente forma,<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><b><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Option Explicit<o:p></o:p></span></b></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Const GWL_STYLE = -16<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Const WS_CAPTION = &HC00000<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><b><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Private Sub UserForm_Initialize()<o:p></o:p></span></b></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Dim lngWindow As Long, lFrmHdl As Long<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> lFrmHdl = FindWindowA(vbNullString, Me.Caption)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> lngWindow = lngWindow And (Not WS_CAPTION)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Call DrawMenuBar(lFrmHdl)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><b><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></b></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><b><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></b></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Un problema que se nos puede presentar al utilizar un formulario sin barra de titulo es que no tenemos manera de cerrarlo si no creamos un botón de cerrar o cambiar su tamaño.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcEtuyPxCB4JU7ikaTIfVlZvJomSV7hkdSaVI4_oubzTZvvd_UR44QXI9stLCIjISTzgA2WJlu1d7sKK4XSfi4g4SB4e_YS5s74FB6IsAwmPpAYoTGFNPRl6lLyW2oDNBuWM0yrQJ1qN2l/s1600/imagenBlog.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcEtuyPxCB4JU7ikaTIfVlZvJomSV7hkdSaVI4_oubzTZvvd_UR44QXI9stLCIjISTzgA2WJlu1d7sKK4XSfi4g4SB4e_YS5s74FB6IsAwmPpAYoTGFNPRl6lLyW2oDNBuWM0yrQJ1qN2l/s1600/imagenBlog.JPG" /></a></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Si quieres aprender mas sobre API pincha <a href="http://en.wikipedia.org/wiki/Application_programming_interface" target="_blank">aquí</a>.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-20816591951816958642012-04-01T01:06:00.003-07:002012-04-08T01:28:35.413-07:00Formas<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Excel utiliza el grupo Formas o “Shapes”, al que se accede seleccionando <i>insertar>>Formas</i> para insertar una forma “Shape” a una hoja de trabajo.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Shapes</span></b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"> (objeto) es la colección de todos los objetos <b>Shape</b> de la hoja especificada, cada objeto <b>Shape</b> representa un objeto de la capa de dibujo, como una autoforma, una forma libre, un objeto OLE o una imagen.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El número del nombre de la forma varía, dependiendo de cuantas formas iguales se haya insertado, por ejemplo si se han incrustado dos rectángulos, el nombre del segundo seria “2 Rectangle”.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Usaremos <b>Shapes</b>(índice), donde índice es el nombre o número de índice de la forma, para obtener un solo objeto <b>Shape</b>. <o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El siguiente procedimiento crea una forma con una textura y aplica algunos efectos y sombras.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub ObShapes()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim shp As Shape<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Set shp = ActiveSheet.Shapes.AddShape(Type:=msoShapeMathMultiply, _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Left:=100, Top:=10, Width:=200, Height:=200)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> With shp<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Line.Visible = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .ThreeD.Visible = True<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .ThreeD.Depth = 60<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .ThreeD.RotationY = 10<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Shadow.Visible = True<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Shadow.Transparency = 0.8<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Shadow.Blur = 12<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Fill.ForeColor.RGB = RGB(255, 0, 0)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End With<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Al trabajar con formas es preferible que el código realice varias acciones, por lo tanto es eficiente crear una variable de objeto.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Nuestro ejemplo quedaría más o menos como la siguiente imagen:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAseXjd3vYoiBtDu5ZG9umKzfNqSoVCzo86mAI9kbPUTNT0PJqf0-4X9tHZ6asoz4sgE0_xixBCkv4XI1Sw7eyIB_ve0hMpKXO_m_y6_PPz8aIQaEtthGyQzk3ZK-V4k0ra-qGjuUmrj7b/s1600/forma.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAseXjd3vYoiBtDu5ZG9umKzfNqSoVCzo86mAI9kbPUTNT0PJqf0-4X9tHZ6asoz4sgE0_xixBCkv4XI1Sw7eyIB_ve0hMpKXO_m_y6_PPz8aIQaEtthGyQzk3ZK-V4k0ra-qGjuUmrj7b/s320/forma.JPG" width="276" /></a></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-73495318635529720572012-03-10T10:12:00.001-08:002012-03-10T10:13:39.175-08:00Trabajar con colores<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Tratar con los colores en Excel no es un asunto trivial, admito que es algo complicado, grabar una macro mientras se cambia el color en una celda u objeto solo genera confusión.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Ahora podemos acceder en un libro a una cantidad de colores prácticamente ilimitada (16.777.216 colores), nadie puede conocer el valor de casi 17 millones de colores.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Podemos cambiar el color de la celda activa a verde utilizando la siguiente instrucción.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub colorVerde()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">ActiveCell.Interior.color = 62280<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Una buena manera de cambiar los colores es especificar el color de acuerdo con sus componentes rojo, verde y azul, el sistema de colores RGB.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El rango de cada uno de estos colores va desde el 0 al 255, por lo tanto el número total de colores posibles seria 256x256x256= 16.777.216 colores.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Para especificar los colores en VB mediante RGB utilizamos la función <b>RGB</b> que nos devuelve un número que representa un valor de color.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Para representar el color del ejemplo anterior con RGB lo haríamos de la siguiente forma.<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub colorVerde()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">ActiveCell.Interior.color = RGB(0, 255, 0)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La siguiente tabla muestra algunos colores estándar y sus valores de rojo, verde y azul:<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin-left: 2.75pt; width: 212px;"><tbody>
<tr style="height: 18.75pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;"> <td style="background: #DDDDDD; border: solid windowtext 1.0pt; height: 18.75pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 33.0pt;" valign="bottom" width="44"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-size: 8pt;">Color<o:p></o:p></span></b></div></td> <td style="background: #DDDDDD; border-left: none; border: solid windowtext 1.0pt; height: 18.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 38.0pt;" valign="bottom" width="51"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-size: 8pt;">Valor de rojo<o:p></o:p></span></b></div></td> <td style="background: #DDDDDD; border-left: none; border: solid windowtext 1.0pt; height: 18.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="bottom" width="59"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-size: 8pt;">Valor de verde<o:p></o:p></span></b></div></td> <td style="background: #DDDDDD; border-left: none; border: solid windowtext 1.0pt; height: 18.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="bottom" width="59"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="font-size: 8pt;">Valor de azul<o:p></o:p></span></b></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 1;"> <td style="border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 33.0pt;" valign="top" width="44"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-size: 8pt;">Negro<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 38.0pt;" valign="top" width="51"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 2;"> <td style="border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 33.0pt;" valign="top" width="44"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-size: 8pt;">Azul<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 38.0pt;" valign="top" width="51"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 3;"> <td style="border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 33.0pt;" valign="top" width="44"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-size: 8pt;">Verde<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 38.0pt;" valign="top" width="51"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 4;"> <td style="border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 33.0pt;" valign="top" width="44"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-size: 8pt;">Cián<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 38.0pt;" valign="top" width="51"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 5;"> <td style="border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 33.0pt;" valign="top" width="44"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-size: 8pt;">Rojo<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 38.0pt;" valign="top" width="51"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 6;"> <td style="border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 33.0pt;" valign="top" width="44"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-size: 8pt;">Magenta<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 38.0pt;" valign="top" width="51"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 7;"> <td style="border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 33.0pt;" valign="top" width="44"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-size: 8pt;">Amarillo<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 38.0pt;" valign="top" width="51"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">0<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 8; mso-yfti-lastrow: yes;"> <td style="border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 33.0pt;" valign="top" width="44"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-size: 8pt;">Blanco<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 38.0pt;" valign="top" width="51"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> <td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 44.0pt;" valign="top" width="59"><div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;"><span style="font-size: 8pt;">255<o:p></o:p></span></div></td> </tr>
</tbody></table><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El siguiente procedimiento nos muestra las 60 variantes de los colores de la paleta de colores (Colores del Tema).<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Quedaría más, menos así: <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8ybYP6hJV44yozuNCF7nS-eWVMTcv2ehS35C0hgvFxaK9Tn7TanK54qRO-T0JFGMT9bEZKnW0SNAMRdfhyJ8yxK4jJN9eW8qdMzZarj3wh2Fjuwa9TQbvSUooMexCX9IzNsCbfO37IJJq/s1600/temaColor.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8ybYP6hJV44yozuNCF7nS-eWVMTcv2ehS35C0hgvFxaK9Tn7TanK54qRO-T0JFGMT9bEZKnW0SNAMRdfhyJ8yxK4jJN9eW8qdMzZarj3wh2Fjuwa9TQbvSUooMexCX9IzNsCbfO37IJJq/s400/temaColor.png" width="400" /></a></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub TemaColores()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Dim r As Long, c As Long<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> For r = 1 To 6<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> For c = 1 To 10<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> With Cells(r, c).Interior<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .ThemeColor = c<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Select Case c<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Select Case r<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 1: .TintAndShade = 0<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 2: .TintAndShade = -0.05<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 3: .TintAndShade = -0.15<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 4: .TintAndShade = -0.25<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 5: .TintAndShade = -0.35<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 6: .TintAndShade = -0.5<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End Select<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 2<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Select Case r<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 1: .TintAndShade = 0<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 2: .TintAndShade = 0.5<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 3: .TintAndShade = 0.35<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 4: .TintAndShade = 0.25<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 5: .TintAndShade = 0.15<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 6: .TintAndShade = 0.05<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End Select<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 3<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Select Case r<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 1: .TintAndShade = 0<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 2: .TintAndShade = -0.1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 3: .TintAndShade = -0.25<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 4: .TintAndShade = -0.5<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 5: .TintAndShade = -0.75<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 6: .TintAndShade = -0.9<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End Select<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case Else<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Select Case r<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 1: .TintAndShade = 0<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 2: .TintAndShade = 0.8<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 3: .TintAndShade = 0.6<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 4: .TintAndShade = 0.4<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 5: .TintAndShade = -0.25<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case 6: .TintAndShade = -0.5<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End Select<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End Select<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Cells(r, c) = .TintAndShade<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End With<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Next c<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Next r<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Cells(x,x).Interior.TintAndShade <o:p></o:p></span></b></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Devuelve o establece un valor que aclara u oscurece un color se escribir un número comprendido entre -1 (más oscuro) y 1 (más claro) para la propiedad <b>TintAndShade</b>; el cero (0) corresponde al valor neutro.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-30443499936886866072012-03-04T10:30:00.001-08:002012-03-04T10:32:57.281-08:00Suma Selectiva<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">En este post, hemos creado un procedimiento que pueda realizar una suma selectiva de acuerdo a una serie de condiciones. Por ejemplo, es posible que quieran sumar las cifras que han alcanzado el objetivo de ventas. <o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Este procedimiento puede resumir los valores que estén por debajo o por encima de un valor dado.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Este procedimiento se iniciara cuando presionemos un botón creado en nuestra hoja, para insertar el botón nos vamos a la ficha programador insertar controles, en controles Activex presionamos en el icono del botón.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9lgS0_SLbtFw1WIl67dM9BtkuW7zr2Y9dgp0pDJQaeRkwgX_DovE1__n0BfbsCcHnd44_8w8TzLL0I1xMR3ss6tv80Zv4vKQsnnyknfBK2iMUBS25ATi-cljl8GfuRIol_cI9N_SBAUJa/s1600/control.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="255" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9lgS0_SLbtFw1WIl67dM9BtkuW7zr2Y9dgp0pDJQaeRkwgX_DovE1__n0BfbsCcHnd44_8w8TzLL0I1xMR3ss6tv80Zv4vKQsnnyknfBK2iMUBS25ATi-cljl8GfuRIol_cI9N_SBAUJa/s400/control.png" width="400" /></a></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Lo pegamos donde nos sea mas accesible, seleccionamos el botón, presionamos sobre el botón derecho del ratón y en el cuadro de dialogo presionamos propiedades.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">En el cuadro de propiedades seleccionamos la propiedad <b>Caption </b>y la cambiamos por el nombre que identifique la función del botón, por ejemplo Suma Selectiva.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6rZ3wqQUggTuTCmzIyXdu8be1WR64S2KF07vFpa1EOtQarEmZ4mJq8o2TknoGR_4ieHf-YuiC9c3azmeQyqgRLwswaDkuyHpaLRPo8j4P3v8M-tvK5fs8NAUgXrBnPn3zydwkAo9hj4Iz/s1600/propiedades.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="253" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6rZ3wqQUggTuTCmzIyXdu8be1WR64S2KF07vFpa1EOtQarEmZ4mJq8o2TknoGR_4ieHf-YuiC9c3azmeQyqgRLwswaDkuyHpaLRPo8j4P3v8M-tvK5fs8NAUgXrBnPn3zydwkAo9hj4Iz/s400/propiedades.png" width="400" /></a></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Hacemos doble click sobre el botón y directamente nos sale el editor de VB con el evento predeterminado del botón que hemos creado, a este evento le añadimos nuestro procedimiento.<o:p></o:p></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Private Sub CommandButton1_Click()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim rng As Range, i As Integer, a As Integer<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim temporal, sumFallida, suma, valorLimite As Single<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">sumFallida = 0<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">suma = 0<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">valorLimite = 0<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Set rng = Application.InputBox("Por favor seleccione el rango de calculo!", _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">"SeleccionarRango", Selection.Address, , , , , 8)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">On Error Resume Next<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">valorLimite = InputBox("Por favor establezca el valor limite!", "SeleccionarValor", , , 6)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">a = rng.Count<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> For i = 1 To a<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> temporal = rng.Cells(i).Value<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Select Case temporal<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case Is < valorLimite<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> sumFallida = sumFallida + temporal<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Case Is >= valorLimite<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> suma = suma + temporal<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End Select<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Next i<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">MsgBox "La suma de los valores menores de " & valorLimite & " es: " & Str(sumFallida) & vbCrLf & _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">"La suma de los valores mayores de " & valorLimite & " es: " & Str(suma)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Cerramos el editor y quitamos el modo diseño de la ficha programador, presionamos sobre el botón y si todo ha salido correctamente nos deberá de salir algo parecido a la siguiente imagen:</span><br />
<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiof9X79y6PSON6i5fb5Mr-KH3jSvph7uf7ZAAGvPql1XlK1MYaXE6qSKMMRWwUZgYVEGvhadB1ahl4QzruCDg0z1kfxiwLQJQIGRrCGULCNlvMGJW6m14jW81d6KJ-gpzWaNaPuci7IAQH/s1600/resultado.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiof9X79y6PSON6i5fb5Mr-KH3jSvph7uf7ZAAGvPql1XlK1MYaXE6qSKMMRWwUZgYVEGvhadB1ahl4QzruCDg0z1kfxiwLQJQIGRrCGULCNlvMGJW6m14jW81d6KJ-gpzWaNaPuci7IAQH/s400/resultado.png" width="400" /></a></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-6158919085803071782012-02-21T03:11:00.001-08:002012-02-21T03:13:30.588-08:00El Objeto QueryTable<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El Objeto <b>QueryTable</b> (Tabla de consulta) representa un rango de datos externos en una hoja de calculo, las fuente externas pueden provenir de un servidor de SQL, una base de datos de Microsoft Access o una consulta Web. <o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El siguiente procedimiento crea una consulta web para importar una tabla específica.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Si copiamos el siguiente procedimiento en un modulo y le damos a ejecutar observaremos que se ha creado una tabla de datos automáticamente, procedente de la pagina web eleconomista, dicha tabla se actualiza automáticamente cada minuto.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub IBEX()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> With ActiveSheet.QueryTables.Add(Connection:= _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> "URL;http://www.eleconomista.es/indice/IBEX-35", Destination:=Range("$A$1"))<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Name = "IBEX-35"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .FieldNames = True<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .RowNumbers = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .FillAdjacentFormulas = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .PreserveFormatting = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .RefreshOnFileOpen = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .BackgroundQuery = True<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .RefreshStyle = xlInsertDeleteCells<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .SavePassword = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .SaveData = True<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .AdjustColumnWidth = True<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .RefreshPeriod = 1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .WebSelectionType = xlSpecifiedTables<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .WebFormatting = xlWebFormattingRTF<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .WebTables = "3"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .WebPreFormattedTextToColumns = True<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .WebConsecutiveDelimitersAsOne = True<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .WebSingleBlockTextImport = True<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .WebDisableDateRecognition = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .WebDisableRedirections = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Refresh BackgroundQuery:=False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End With<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Este procedimiento lo podemos dividir en tres partes principales, donde creamos la consulta con <b>ActiveSheet.QueryTables.Add </b>, las propiedades de la tabla importada donde indicamos con <b>RefreshPeriod</b> la periodicidad con la que queremos que se actualice la tabla desde la página web, y por ultimo las opciones de importar, que como parte importante tenemos la opción <b>WebTables</b> donde indicamos el número de índice de tabla que queremos importar.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-90936392156949376122012-02-12T10:50:00.000-08:002012-02-12T10:51:19.320-08:00Eventos no asociados a Objetos<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Cada objeto lleva asociados unos determinados eventos que le pueden ocurrir, por ejemplo a un botón o una hoja, puede ocurrir que al activar la hoja queramos que se produzca una determinada acción, este evento seria <b><i>Private Sub Worksheet_Activate(), </i></b>al cual nosotros le añadiremos el código de lo que queremos que haga la aplicación cuando se active la hoja.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Los dos eventos que vamos a comentar no están asociados a un objeto. En su lugar se accede a ellos mediante métodos del objeto de <b>Application.</b><o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><b><br />
</b></span></div><div class="MsoNormal"><b><u><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Evento OnTime:<o:p></o:p></span></u></b></div><div class="MsoNormal"><b><u><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></u></b></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El evento <b>OnTime</b> tiene lugar en una hora concreta en el futuro, lo que podemos utilizar para lograr la ejecución automática de macros de Exce</span>l, por ejemplo.<o:p></o:p></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La siguiente instrucción ejecuta el procedimiento de Alarma a las 07:00 a.m. del próximo 14 de Febrero (día de los enamorados).<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub Ejec_Alarma()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Application.OnTime DateSerial(2012, 2, 14) + TimeValue("07:00:00"), "Msg_Alarma"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Mensaje de alarma..<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub Msg_Alarma()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim n As Integer<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">For n = 1 To 20<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Beep<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Next n<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">MsgBox "Hoy es el día de los enamorados..", vbInformation, "ALARMA"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Para cancelar el evento <b>OnTime</b> utilizaremos la siguiente instrucción.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Application.OnTime DateSerial (2012, 2, 14) + _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">TimeValue("07:00:00"), "Msg_Alarma", , False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal"><b><u><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Evento OnKey:<o:p></o:p></span></u></b></div><div class="MsoNormal"><b><u><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></u></b></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El evento<b> OnKey</b> ejecuta un procedimiento específico cuando una tecla o combinación de teclas se pulsan.</span> <o:p></o:p></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">A continuación os relaciono una matriz con los códigos que representa cada tecla en el teclado.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin-left: 2.75pt; width: 244px;"><tbody>
<tr style="height: 13.5pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;"> <td style="background: #E5E5E5; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">Clave<o:p></o:p></span></div></td> <td style="background: #E5E5E5; border-left: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">Código<o:p></o:p></span></div></td> </tr>
<tr style="height: 18.75pt; mso-yfti-irow: 1;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">RETROCESO<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{RETROCESO}</span><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;"> o </span><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{BS}<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 2;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">BREAK<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{PAUSA}<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 3;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">CAPS LOCK<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{} BLOQ MAYÚS<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 4;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">CLEAR<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{CLEAR}<o:p></o:p></span></div></td> </tr>
<tr style="height: 18.75pt; mso-yfti-irow: 5;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">SUPR o DEL<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{DELETE}</span><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;"> o </span><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{DEL}<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 6;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">FLECHA ABAJO<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{DOWN}<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 7;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">FIN<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{END}<o:p></o:p></span></div></td> </tr>
<tr style="height: 18.75pt; mso-yfti-irow: 8;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">ENTER (teclado numérico)<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{ENTER}<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 9;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">ENTER<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">~</span><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;"> (tilde)</span><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;"><o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 10;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">CES<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">{ </span><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">Salir}</span><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;"> o </span><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{ESC}</span><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;"><o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 11;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">AYUDA<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{AYUDA}<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 12;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">INICIO<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{HOME}<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 13;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">INS<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{INSERT}<o:p></o:p></span></div></td> </tr>
<tr style="height: 18.75pt; mso-yfti-irow: 14;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">FLECHA A LA IZQUIERDA<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{Left}<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 15;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">BLOQ NUM<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{BLOQ NUM}<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 16;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">PÁG<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{} PGDN<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 17;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">PÁG<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{} PGUP<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 18;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">REGRESAR<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{Return}<o:p></o:p></span></div></td> </tr>
<tr style="height: 18.75pt; mso-yfti-irow: 19;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">FLECHA A LA DERECHA<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{Derecha}<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 20;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">SCROLL LOCK<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{} ScrollLock<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 21;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">TAB<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{TAB}<o:p></o:p></span></div></td> </tr>
<tr style="height: 18.75pt; mso-yfti-irow: 22;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">FLECHA ARRIBA<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{UP}<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 23; mso-yfti-lastrow: yes;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 91.0pt;" width="121"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">F1 a F15<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 92.0pt;" width="123"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{F1}</span><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;"> a través </span><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">{F15}<o:p></o:p></span></div></td> </tr>
</tbody></table><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">También se pueden especificar en combinación con las teclas SHIFT , CTRL y ALT.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin-left: 2.75pt; width: 259px;"><tbody>
<tr style="height: 18.75pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;"> <td style="background: #E5E5E5; border: solid #BBBBBB 1.0pt; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 98.2pt;" width="131"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">Para combinar con las teclas<o:p></o:p></span></div></td> <td style="background: #E5E5E5; border-left: none; border: solid #BBBBBB 1.0pt; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.15pt;" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">Precede el código clave por<o:p></o:p></span></div></td> </tr>
<tr style="height: 13.5pt; mso-yfti-irow: 1;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 98.2pt;" width="131"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">SHIFT<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 13.5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.15pt;" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">+</span><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;"> (signo más)</span><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;"><o:p></o:p></span></div></td> </tr>
<tr style="height: 18.75pt; mso-yfti-irow: 2;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 98.2pt;" width="131"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">CTRL<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.15pt;" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">^</span><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;"> (acento circunflejo)</span><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;"><o:p></o:p></span></div></td> </tr>
<tr style="height: 18.75pt; mso-yfti-irow: 3; mso-yfti-lastrow: yes;"> <td style="background: white; border-top: none; border: solid #BBBBBB 1.0pt; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 98.2pt;" width="131"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;">ALT<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid #BBBBBB 1.0pt; border-left: none; border-right: solid #BBBBBB 1.0pt; border-top: none; height: 18.75pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.15pt;" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;">%</span><span style="font-family: 'Segoe UI', sans-serif; font-size: 7pt;"> (signo de porcentaje)</span><span style="font-family: 'Arial Unicode MS', sans-serif; font-size: 7pt;"><o:p></o:p></span></div></td> </tr>
</tbody></table><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Pegue las siguientes instrucciones en un módulo:</span><o:p></o:p></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub DemoOnKey()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Application.OnKey "{TAB}", "Message"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub Message()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> MsgBox "Hola"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Vemos que al pulsar el tabulador se ejecuta el mensaje.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-88624317402153182722012-02-05T01:19:00.000-08:002012-02-11T00:01:10.599-08:00Forzar Cierre<div class="MsoNormal" style="background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Los procedimientos que se relacionan a continuación son complementos que puedes utilizar en cualquier código realizado por ti, de modo que cuando el procedimiento se complete, se apague automáticamente tu sistema.<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">En suma, es una muy buena aplicación que nos puede ayudar de muchas maneras. <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">El comando <b>shutdown</b> permite a un usuario apagar un equipo desde la línea de comandos de Windows (cmd), los argumentos son los siguientes:<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: 12.75pt; margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin-left: 2.75pt; width: 498px;"><tbody>
<tr style="height: 12.75pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;"> <td nowrap="" style="background: white; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.35pt;" valign="top" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Sin argumentos<o:p></o:p></span></div></td> <td nowrap="" style="background: white; border-left: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 277.3pt;" width="370"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Mostrar este mensaje (lo mismo que -?)<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 1;"> <td nowrap="" style="background: white; border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.35pt;" valign="top" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">-I<o:p></o:p></span></div></td> <td nowrap="" style="background: white; border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 277.3pt;" width="370"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Mostrar interfaz GUI, debe ser la primera opción<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 2;"> <td nowrap="" style="background: white; border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.35pt;" valign="top" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">-L<o:p></o:p></span></div></td> <td nowrap="" style="background: white; border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 277.3pt;" width="370"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Cierre la sesión (no se puede utilizar con la opción-m)<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 3;"> <td nowrap="" style="background: white; border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.35pt;" valign="top" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">-S<o:p></o:p></span></div></td> <td nowrap="" style="background: white; border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 277.3pt;" width="370"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Apagar el equipo<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 4;"> <td nowrap="" style="background: white; border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.35pt;" valign="top" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">-R<o:p></o:p></span></div></td> <td nowrap="" style="background: white; border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 277.3pt;" width="370"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Apagar y reiniciar el equipo<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 5;"> <td nowrap="" style="background: white; border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.35pt;" valign="top" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">-Una<o:p></o:p></span></div></td> <td nowrap="" style="background: white; border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 277.3pt;" width="370"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Anular el apagado del sistema<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 6;"> <td nowrap="" style="background: white; border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.35pt;" valign="top" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">-M \ \ equipo<o:p></o:p></span></div></td> <td nowrap="" style="background: white; border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 277.3pt;" width="370"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">El equipo remoto para apagar / reiniciar / cancelar<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 7;"> <td nowrap="" style="background: white; border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.35pt;" valign="top" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">-T xx<o:p></o:p></span></div></td> <td nowrap="" style="background: white; border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 277.3pt;" width="370"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Ajuste de tiempo de espera de apagado en xx segundos<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 8;"> <td nowrap="" style="background: white; border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.35pt;" valign="top" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">-C "comentario"<o:p></o:p></span></div></td> <td nowrap="" style="background: white; border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 277.3pt;" width="370"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Comentario de apagado (máximo de 127 caracteres)<o:p></o:p></span></div></td> </tr>
<tr style="height: 12.75pt; mso-yfti-irow: 9;"> <td nowrap="" style="background: white; border-top: none; border: solid windowtext 1.0pt; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.35pt;" valign="top" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">-F<o:p></o:p></span></div></td> <td nowrap="" style="background: white; border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 277.3pt;" width="370"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Fuerza el cierre de aplicaciones sin previo aviso<o:p></o:p></span></div></td> </tr>
<tr style="height: 52.5pt; mso-yfti-irow: 10; mso-yfti-lastrow: yes;"> <td nowrap="" style="background: white; border-top: none; border: solid windowtext 1.0pt; height: 52.5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 96.35pt;" valign="top" width="128"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">-D [u] [p]: xx: yy<o:p></o:p></span></div></td> <td style="background: white; border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 52.5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 3.5pt 0cm 3.5pt; width: 277.3pt;" width="370"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">El código de motivo de apagado <br />
u es el código de usuario <br />
p es un proyecto de código de parada <br />
xx es el código de las principales razones (entero positivo menor que 256) <br />
yy es el código secundario del motivo (entero positivo menor que 65536)<o:p></o:p></span></div></td> </tr>
</tbody></table><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Este comando lo utilizaremos en nuestro código con distintas combinaciones para forzar a nuestro sistema al cierre, al igual que utilizamos<b> shutdown</b> también podríamos utilizar cualquier otro comando del cmd, esto lo dejo a vuestra imaginación...<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><o:p><a href="http://es.wikipedia.org/wiki/S%C3%ADmbolo_del_sistema" target="_blank">Comandos cmd</a></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span lang="EN-US" style="font-size: 10pt; line-height: 115%;"></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-size: x-small;"><span style="line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;">Sub ApagarPC()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> ActiveWorkbook.Save<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> Application.DisplayAlerts = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> Application.Quit<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> Shell "shutdown -s -t 02", vbHide<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="background-color: white;"><span lang="EN-US" style="color: #351c75; font-size: 10pt; line-height: 115%;"></span></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;">Sub ReiniciarPC()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> ActiveWorkbook.Save<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> Application.DisplayAlerts = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> Application.Quit<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> Shell "shutdown -r -t 02", vbHide<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="background-color: white;"><span lang="EN-US" style="color: #351c75; font-size: 10pt; line-height: 115%;"></span></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;">Sub ForzarPC()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> ActiveWorkbook.Save<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> Application.DisplayAlerts = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> Application.Quit<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="background-color: white; color: #351c75; font-size: 10pt; line-height: 115%;"> Shell "shutdown -r -f -t 02", vbHide<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #351c75; font-size: 10pt; line-height: 115%;"><span style="background-color: white;">End Sub</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="font-size: 10pt; line-height: 115%;"><br />
</span></div><br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Espero que os sea de utilidad…..<span style="color: #000066;"><o:p></o:p></span></span></div><div class="MsoNormal" style="color: #000066; margin-bottom: 0.0001pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-27436071669146234002012-01-26T15:57:00.000-08:002012-01-26T16:04:23.316-08:00Comunicación con Outlook<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Continuando con la interacción entre los distintos programas de Microsoft con Excel esta vez le toca el turno a Outlook.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El procedimiento que viene a continuación nos permite crear mensajes (mails) Outlook y enviar el libro activo como dato adjunto.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Antes de ejecutar el procedimiento deberemos de seleccionar la referencia <b>Microsoft Outlook 14.0 Object Librery</b> desde el menú herramientas.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoujbYaxgQ7CVJmAt_19VbvqGVT2oriGFBp7URgpN0AGvpsvivuU55Hgiw0CxKAEVtyhc9xe5Cr3zwuiR8VCh7nGS9QB77YzLvLU_SlIFGPETkB1G_MFlBLuNFvdvBr8CpfkIfwSgtZZHd/s1600/correo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoujbYaxgQ7CVJmAt_19VbvqGVT2oriGFBp7URgpN0AGvpsvivuU55Hgiw0CxKAEVtyhc9xe5Cr3zwuiR8VCh7nGS9QB77YzLvLU_SlIFGPETkB1G_MFlBLuNFvdvBr8CpfkIfwSgtZZHd/s1600/correo.png" /></a></div><div class="MsoNormal"><br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">A continuación copiamos el procedimiento en un modulo.<o:p></o:p></span></div></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub EnviarCorreo()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim appOutlook As Outlook.Application<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim mensage As Outlook.MailItem<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Set appOutlook = CreateObject("outlook.application")<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Set mensage = appOutlook.CreateItem(olMailItem)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">With mensage<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Subject = "Prueba"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Body = " Prueba con datos adjuntos..... "<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .BodyFormat = olFormatHTML<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Recipients.Add ("Nombre1")<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Recipients.Add ("Nombre2")<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Attachments.Add ThisWorkbook.Path & "\" & ThisWorkbook.Name<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Display<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Send<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End With<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">appOutlook.Quit<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Set appOutlook = Nothing<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Para probar el ejemplo debes remplazar la palabra nombre(x) por nombres que figuren en la lista de contactos de Outlook.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">De este procedimiento cabe destacar el método <b>CreateItem (olMailItem)</b> que crea un nuevo <a href="http://www.blogger.com/post-create.g?blogID=1091239317608127959"><span style="color: windowtext; text-decoration: none;">elemento </span></a>(mensaje de correo electrónico) de Microsoft Outlook.<o:p></o:p></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El resto de propiedades y métodos no nos extenderemos más ya que los hemos utilizado en otras ocasiones…</span><br />
<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-21364702038685517092012-01-21T10:20:00.000-08:002012-01-21T10:20:03.497-08:00Tablas dinámicas<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">Las tablas dinámicas son muy útiles para estructurar datos que se presentan en bruto, resumirlos y crear informes. Normalmente, una tabla de datos de Excel no puede cambiar de estructura. Podemos ordenar los datos, filtrarlos, añadir subtotales, pero la estructura en filas y columnas es inalterable. Uno de los objetivos de las tablas dinámicas es la posibilidad de alterar esa estructura y a la vez resumir datos.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">El siguiente procedimiento establece las bases principales de utilización de VBA para crear una tabla dinámica. El código que utilizamos puede resultar un poco confuso.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">A continuación explico brevemente algunos objetos relevantes:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal"><b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><span style="color: windowtext; text-decoration: none; text-underline: none;">PivotCaches:</span></span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> Representa todas la memoria caché de tabla dinámica del libro especificado.<o:p></o:p></span></div><div class="MsoNormal"><b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><span style="color: windowtext; text-decoration: none; text-underline: none;">PivotTable:</span> </span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> Colección de todos los objetos de la hoja de cálculo especificada.<o:p></o:p></span></div><div class="MsoNormal"><b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">PivotFields: </span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">Representa un solo campo de tabla dinámica.<o:p></o:p></span></div><div class="MsoNormal"><b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">DisplayFieldCaptions:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> Controla si se muestran o no los botones de filtro y los títulos <b>PivotField</b> para filas y columnas en la cuadrícula.<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Sub PivotTable()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Dim PTCache As PivotCache<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Dim PT As PivotTable<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Set PTCache = ActiveWorkbook.PivotCaches.Create _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">(SourceType:=xlDatabase, SourceData:=Range("A1").CurrentRegion)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">Set PT = ActiveSheet.PivotTables.Add(PivotCache:=PTCache, _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">TableDestination:=Range("F1"), TableName:="Ventas")<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">With PT<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> .PivotFields("Zona").Orientation = xlPageField<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> .PivotFields("Mes").Orientation = xlColumnField<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> .PivotFields("Nombre").Orientation = xlRowField<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> .PivotFields("Ventas").Orientation = xlDataField<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;"> .DisplayFieldCaptions = False<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">End With<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: ES-TRAD;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">La última sección del código se añade los campos a la tabla dinámica y se especifica su localización dentro de ella.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">El código también podría ser más general si se utiliza índices en lugar de cadenas literales para las colecciones <b>PivotFields</b>. De esta forma, si el usuario cambia los encabezados de las columnas, el código seguirá funcionando.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSIFnYqIKAZFWoTJ0oD5MQEu8U4IbtYpaGFbDKAmmqgf7KDnkZLGDzS2MeOvTR8oLBDQoenh8BR6xWha0INTuetIvTw00GPjUf9EHdEtjzNlglXmMJ1-8DoWEyzyAG7wB3SBRqUskcg8uC/s1600/tabladimamica.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="277" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSIFnYqIKAZFWoTJ0oD5MQEu8U4IbtYpaGFbDKAmmqgf7KDnkZLGDzS2MeOvTR8oLBDQoenh8BR6xWha0INTuetIvTw00GPjUf9EHdEtjzNlglXmMJ1-8DoWEyzyAG7wB3SBRqUskcg8uC/s400/tabladimamica.JPG" width="400" /></a></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-79180173343709721392012-01-16T00:19:00.000-08:002012-01-16T15:17:01.658-08:00Barra de Progreso<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Una de las necesidades más comunes para un programador de Excel es indicar visualmente al usuario el progreso de la ejecución de una tarea y para ello utilizan la barra de progreso.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La barra de progreso es el elemento (normalmente representado por un formulario) que nos permiten mostrar de forma gráfica (parecido a un termómetro) el estado del avance de una tarea o proceso. Generalmente el gráfico está acompañado de información en forma de texto para medir con exactitud el avance.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Un indicador de progreso <u>ralentiza</u> un poco la ejecución de la macro, por eso si la rapidez de la macro es crucial en nuestro libro será mejor no utilizarla.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El siguiente procedimiento genera mediante bucles una serie de números aleatorios, según se ejecutan realizan una serie de cambios en el formulario que hemos creado con anterioridad y que nos quedaría de la siguiente forma.</span></div><div class="MsoNormal"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-MpLpMZVc3cgISMTSTZjIAOujWrr33rVoOOixNb3ifeOnOb5fwehMSPa0jZ5kl2UTy775uaQ8vuSgg35pdkbQrj1xnwMkiicAMFZpU0LNnWtkqYK2hH8mJ0PwS8Mji3VgWYULtvBpA8SM/s1600/Barra+de+Progreso.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-MpLpMZVc3cgISMTSTZjIAOujWrr33rVoOOixNb3ifeOnOb5fwehMSPa0jZ5kl2UTy775uaQ8vuSgg35pdkbQrj1xnwMkiicAMFZpU0LNnWtkqYK2hH8mJ0PwS8Mji3VgWYULtvBpA8SM/s1600/Barra+de+Progreso.JPG" /></a></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El formulario Progreso contiene los siguientes elementos:<o:p></o:p></span></div><div class="MsoNormal"></div><ul><li><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Control de marco (Frame1)</span></li>
<li><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Control de etiqueta (Lavel1)</span><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"> </span><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">que simula la barra de progreso.</span></li>
<li><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Control de etiqueta (Lavel2) opcional</span></li>
</ul><br />
<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">En un modulo copiamos los siguientes procedimientos:<o:p></o:p></span></div></div><div class="MsoNormal"><span lang="ES"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub GeneradorNumeros()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Const RowMax As Integer = 500<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Const ColMax As Integer = 40<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim Cuenta As Integer<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim r As Integer, c As Integer<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim Pct As Single<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Cells.Clear<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> For r = 1 To RowMax<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> For c = 1 To ColMax<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Cells(r, c) = Int(Rnd * 49)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Cuenta = Cuenta + 1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Next c<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Pct = Cuenta / (RowMax * ColMax)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Call Progreso(Pct)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Next r<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Unload UserForm1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub Progreso(n)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">With UserForm1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Frame1.Caption = Format(n, "0%")<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Label1.Width = n * (.Frame1.Width - 10)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Repaint<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End With<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub ShowDialog()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">UserForm1.Label1.Width = 0<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">UserForm1.Show<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Insertamos el siguiente procedimiento en la ventana de código del <b>UserForm1</b>, este procedimiento solo invoca al generador de números y nos colorea la etiqueta (Lavel1) con el color del tema de nuestro libro.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Como os podéis dar cuenta este procedimiento se escribe en el evento <b>Activate</b> del formulario que se desencadena cuando se muestra el formulario. <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Private Sub UserForm_Activate()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">UserForm1.Label1.BackColor = </span><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">ActiveWorkbook.Theme. _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">ThemeColorScheme.Colors(msoThemeAccent1)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Call GeneradorNumeros<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Para iniciar el proceso ejecutamos la macro <b>ShowDialog</b> desde el cuadro de dialogo de Macro en la ficha programador.<o:p></o:p></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-70378786951240901882012-01-08T15:04:00.000-08:002012-01-08T15:24:34.464-08:00Cuadros de dialogo Segunda Parte<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><a href="http://vbaparaaplicacionesexcel.blogspot.com/2011/11/cuadro-de-dialogo.html">Enlace de la primera parte.</a><o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><b><span style="font-family: 'Times New Roman', serif; font-size: 14pt; line-height: 115%;">Método GetOpenFilename:<o:p></o:p></span></b></div><div class="MsoNormal"><b><span style="font-family: 'Times New Roman', serif; font-size: 14pt; line-height: 115%;"><br />
</span></b></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Método <b>GetOpenFilename</b> es un objeto de <b>Application</b>, que obtiene un nombre de archivo correcto a través de un cuadro de dialogo. Este método muestra el habitual cuadro de dialogo de <b>Abrir</b>, pero no abre realmente el archivo especificado, el método devuelve la cadena que contiene la ruta y el nombre del archivo seleccionado por nosotros.<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La sintaxis para este método es la siguiente: (todo es opcional)<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><b><i><span lang="EN-US" style="font-family: 'Times New Roman', serif; line-height: 115%;">GetOpenFilename ( FileFilter , FilterIndex , Título , ButtonText , MultiSelect )<o:p></o:p></span></i></b></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">En este ejemplo se muestra el cuadro de diálogo con el filtro de archivos definido como archivos de Word.<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub SelectArchivo()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim RutaArchivo As String<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">MsgBox ("Seleccione el archivo de Word que desee.")<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">RutaArchivo = Application.GetOpenFilename _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> ("Documento de texto (*.docx), *.docx")<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">On Error GoTo Control:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">MsgBox ("El archivo seleccionado es: " & RutaArchivo)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Control:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRRFJ2tZu_mnpq-04-pT5pBkzRX3d1wCfvpS8gp60VwNc41DGYXaoccl-L530XWWSuq8jTMIdSKJGL57HhcrZqKG-8bMs87vXl-oqktJHdGzjTmzF46cvQCEP9OkuQIN6Ms9qd0thmfXJ8/s1600/Captura.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="313" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRRFJ2tZu_mnpq-04-pT5pBkzRX3d1wCfvpS8gp60VwNc41DGYXaoccl-L530XWWSuq8jTMIdSKJGL57HhcrZqKG-8bMs87vXl-oqktJHdGzjTmzF46cvQCEP9OkuQIN6Ms9qd0thmfXJ8/s400/Captura.JPG" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><br />
</div><div class="MsoNormal"><b><span style="font-family: 'Times New Roman', serif; font-size: 14pt; line-height: 115%;">Método GetSaveAsFilename:</span></b><b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><o:p></o:p></span></b></div><div class="MsoNormal"><b><span style="font-family: 'Times New Roman', serif; font-size: 14pt; line-height: 115%;"><br />
</span></b></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El método <b>GetSaveAsFilename</b> es muy similar al <b>GetOpenFilename</b> muestra el cuadro de diálogo estándar de <b>Guardar como</b> y obtiene el nombre de archivo seleccionado por nosotros sin guardar realmente ningún archivo.<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La sintaxis para este método es la siguiente: (todo es opcional)<o:p></o:p></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><b><i><span lang="EN-US" style="font-family: 'Times New Roman', serif; line-height: 115%;">GetSaveAsFilename(InitialFilename, FileFilter, FilterIndex, Title, ButtonText)<o:p></o:p></span></i></b></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Como diferencia al anterior metodo la opción <b>InitialFilename</b> nos sugiere el nombre de archivo, si este argumento se omite, Microsoft Excel usará el nombre del libro activo.<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub SaveArchivo()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim RutaArchivo As String<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> RutaArchivo = Application.GetSaveAsFilename _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> (FileFilter:="Documento de Excel (*.xlm), *.xlm")<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">On Error GoTo Control:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> ActiveWorkbook.SaveAs (RutaArchivo)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> </span><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">MsgBox "El archivo : " & RutaArchivo & _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> vbCrLf & " se ha guardado correctamente.", vbInformation<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Control:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-38872878594262745612012-01-06T01:12:00.000-08:002012-01-06T15:11:26.844-08:00Crear un menú contextual<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Con Excel VBA podemos crear nuestro propio menú contextual y hacer que aparezcan como respuesta a un evento determinado. El código que presento a continuación crea un sencillo menú con tres elementos.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub CrearMenu()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Set myBar = CommandBars.Add _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> (Name:="MyMenu", Position:=msoBarPopup, _<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Temporary:=True)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Set myItem = myBar.Controls.Add(Type:=msoControlButton)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> With myItem<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Caption = "&Formato Numero..."<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .OnAction = "ShowFormatNumber"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .FaceId = 1554<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End With<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Set myItem = myBar.Controls.Add(Type:=msoControlButton)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> With myItem<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Caption = "&Alineacion..."<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .OnAction = "ShowFormatAlignment"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .FaceId = 217<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End With<o:p></o:p></span><br />
<span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Set myItem = myBar.Controls.Add(Type:=msoControlButton)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> With myItem<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .Caption = "&Fuente..."<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .OnAction = "ShowFormatFont"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> .FaceId = 291<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End With<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><span style="color: windowtext; text-decoration: none;">CommandBars</span></span></b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"> representa la barra de menús y todas las barras de herramientas de Microsoft Office.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La propiedad <b>OnAction</b> Devuelve o establece el nombre de un procedimiento de Visual Basic que se ejecutará cuando hacemos clic al valor de un control de nuestro menú.</span><o:p></o:p></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función <b>FaceId</b> establece el número de Id. de la imagen de un control de nuestro menú.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Después de crear nuestro menú contextual, podemos mostrarlo mediante el método <b>ShowPopup</b>.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El siguiente procedimiento localizado en el modulo de código de un objeto Worksheet, se ejecuta cuando hacemos clic con el botón derecho en una celda.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">CommandBars("MyMenu").ShowPopup<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Nos quedaría como la siguiente imagen:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOBfEHcwVKUio0YJ9lNKEmBv8_ptsTnabAXZfx0ch-gICQ6O92TIxlkRnYAnGn-dhGVrp7M0Us4fzzDKnPqmLbnjFBT_Afq5M7Nf-t1loCTLjYEb3byHkkIWQSKcGrC0t6tMWjhFMVWI0A/s1600/Dibujo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="230" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOBfEHcwVKUio0YJ9lNKEmBv8_ptsTnabAXZfx0ch-gICQ6O92TIxlkRnYAnGn-dhGVrp7M0Us4fzzDKnPqmLbnjFBT_Afq5M7Nf-t1loCTLjYEb3byHkkIWQSKcGrC0t6tMWjhFMVWI0A/s320/Dibujo.jpg" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-64349097477377608662011-12-30T10:58:00.000-08:002011-12-30T11:16:49.521-08:00Procesar serie de Archivos<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Uno de los usos mas comunes que le damos a las macros es el de repetir una operación un determinado numero de veces. El ejemplo que exponemos a continuación nos muestra como manejar diferentes archivos almacenados en el disco.<o:p></o:p></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Lo primero que hacemos es dar las especificaciones que deben de cumplir los archivos que queremos manejar, en este caso de texto.<o:p></o:p></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Como nota importante, al iniciar el procedimiento y al no saber que cantidad de archivos nos puede dar la búsqueda, utilizamos la instrucción <b>ReDim</b> para redimensionar la matriz preservando (Preserve) los datos.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub ProcesoMatriz()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim ArchivoSpec As String<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim i As Integer<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim NombreArchivo As String<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim ListaArchivos() As String<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim ArchivosEncontrados As Integer<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">ArchivoSpec = ThisWorkbook.Path & "\" & "*.txt"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">NombreArchivo = Dir(ArchivoSpec)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> If NombreArchivo <> "" Then<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> ArchivosEncontrados = 1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> ReDim Preserve ListaArchivos(1 To ArchivosEncontrados)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> ListaArchivos(ArchivosEncontrados) = NombreArchivo<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Else<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> MsgBox "No se encontraron archivos que coinciden con " & ArchivoSpec<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Exit Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End If<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Do<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> NombreArchivo = Dir<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> If NombreArchivo = "" Then Exit Do<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> ArchivosEncontrados = ArchivosEncontrados + 1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> ReDim Preserve ListaArchivos(1 To ArchivosEncontrados)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> ListaArchivos(ArchivosEncontrados) = NombreArchivo & "*"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Loop<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> For i = 1 To ArchivosEncontrados<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Call ProcesaArchivo(ListaArchivos(i))<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> Next i<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función <b>Dir</b> nos devuelve el nombre de un archivo, directorio o carpeta que coincide con el patrón o atributo de archivo especificado.<o:p></o:p></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">En este caso, importamos el archivo e introducimos una serie de formulas de resumen que describen los datos del archivo.<o:p></o:p></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Los archivos que cumplen la especificación dada se almacenan en la Matriz <b>ListaArchivos</b>, el procedimiento utiliza el bucle <b>For – Next</b> para procesarlos. Dentro del bucle llamamos al procedimiento <b>ProcesarArchivo</b>.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El procedimiento <b>ProcesarArchivo</b> importa el archivo y luego inserta las cinco formulas.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub ProcesaArchivo(NombreArchivo As String)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Workbooks.OpenText Filename:=NombreArchivo<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Range("D1").Value = "A"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Range("D2").Value = "B"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Range("D3").Value = "C"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Range("E1:E3").Formula = "=COUNTIF(A:A,D1)"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Range("F1:F3").Formula = "=SUMAIF(A:A,D1,B:B)"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal"><br />
<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El método <b>Workbooks.OpenText</b> </span>Carga y redistribuye un archivo de texto en forma de libro nuevo con una sola hoja que contiene los datos redistribuidos del archivo de texto.<o:p></o:p></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Cualquier duda al respecto de lo comentado en el post no dudéis en exponerlo.<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-45938807843525296832011-12-25T16:29:00.000-08:002011-12-25T16:52:26.152-08:00Función Shell de VBA<div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función Shell de VBA nos facilita considerablemente el inicio de otros programas. En el siguiente ejemplo que presento a continuación nos permite iniciar la aplicación <b>Command Prompt</b> (cmd).<o:p></o:p></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub AbrirAplicacion()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim programa As String<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim Ide As Double<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> On Error Resume Next<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">programa = "cmd.exe"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Ide = Shell(programa, vbNormalFocus)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> If Err <> 0 Then<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> MsgBox "No se puede iniciar " & programa, vbCritical, " Error"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> End If<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><o:p><br />
</o:p></span></div><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-se2_8U--CFY/Tve_97rwFMI/AAAAAAAAE1U/9VIHpftBG8Q/s1600/CapturaCmd.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="196" src="http://1.bp.blogspot.com/-se2_8U--CFY/Tve_97rwFMI/AAAAAAAAE1U/9VIHpftBG8Q/s320/CapturaCmd.JPG" width="320" /></a></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
<pre><span style="color: windowtext; font-family: 'Times New Roman', serif; font-size: 12pt;">La función <b>Shell</b> nos devuelve el número de identificación de la tarea para la aplicación. Posteriormente utiliza este número para activar la aplicación, el segundo argumento determina la forma de mostrar la aplicación, en este caso <b>vbNormalFocus</b> hace que la aplicación se ejecuta normalmente y reciba el enfoque.<o:p></o:p></span></pre><pre><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Si la función Shell no funciona genera un error, por eso empleamos una declaración </span><b style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">On Error</b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"> para mostrar el mensaje de “</span><i style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">No se puede iniciar cmd.exe</i><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">”.</span></pre><pre><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Es importante saber que mientras se ejecuta la aplicación que hemos iniciado si el procedimiento tiene mas instrucciones estas continúan ejecutándose, es decir no tiene un intervalo de tiempo constante entre cada evento</span>.</pre><div class="MsoNormal"><o:p></o:p></div><div class="MsoNormal"><br />
</div></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-18511834198140668732011-12-15T01:24:00.000-08:002011-12-25T16:27:01.576-08:00Comunicación con Access<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span class="Apple-style-span" style="font-family: 'Times New Roman', serif; font-size: 16px; line-height: 18px;">Al igual que hicimos con Word en una </span><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">publicación</span><span class="Apple-style-span" style="font-family: 'Times New Roman', serif; font-size: 16px; line-height: 18px;"><a href="http://vbaparaaplicacionesexcel.blogspot.com/2011/11/comunicacion-con-word.html"> anterior</a> esta vez lo haremos con Access utilizando como referencia “microsoft activex data objects 6.0 library” en mi caso, aunque vosotros podréis tener una versión inferior si utilizáis Excel 2007.</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span class="Apple-style-span" style="font-family: 'Times New Roman', serif; font-size: 16px; line-height: 18px;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbdNBWuiE1xPEkk8FaXoGlgo_IIBb-K1gukqjp3iiPG-oLFKVEpTNhvv-dPTyT1R_Yw2BIfcVoMsi3gDH_kZegRoNjJvyxqY5efaL2ztkv0A9BUQiwMxgvAaUTbyQjglBjjTONEjuwWyPi/s1600/Captura.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="253" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbdNBWuiE1xPEkk8FaXoGlgo_IIBb-K1gukqjp3iiPG-oLFKVEpTNhvv-dPTyT1R_Yw2BIfcVoMsi3gDH_kZegRoNjJvyxqY5efaL2ztkv0A9BUQiwMxgvAaUTbyQjglBjjTONEjuwWyPi/s320/Captura.JPG" width="320" /></a></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span class="Apple-style-span" style="font-family: 'Times New Roman', serif; font-size: 16px; line-height: 18px;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Cada biblioteca utiliza memoria y reduce el rendimiento, no utilicemos bibliotecas que sabemos que no son necesarias para nuestra aplicación.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Después de especificar la biblioteca, estamos listos para iniciar el código que nos comunicara con la base de datos.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Para que nos sea más sencillo reconocer cada una de los objetos y propiedades que utilizamos analizaremos paso a paso (análisis forense) cada línea de código.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Abrimos el procedimiento.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub ExportarDB()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Declaramos los objetos ADO (ActiveX Data Objects</span><span class="apple-converted-space"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #4b5358; font-family: Verdana, sans-serif; font-size: 8.5pt; line-height: 115%;"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">) que utilizaremos.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim Datos As New ADODB.Recordset<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El objeto <b>Recordset</b> de ADO se utiliza para mantener un conjunto de registros de una tabla de base de datos. <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">En ADO, este objeto es el más importante y el más usado para manipular los datos de una base de datos.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim Conexion As New ADODB.Connection<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">El objeto <b>connection</b> de ADO se utiliza para crear una conexión abierta a un origen de datos, a través de esta conexión, se puede acceder y manipular una base de datos.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim CaminoConexion As String<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Dim InstruccionSQL As String<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Desactivamos la actualización de la pantalla...</span><span style="color: #00b050; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Application.ScreenUpdating = False <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Seleccionamos la hoja donde copiaremos los datos.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Hoja1.Select <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Seleccionamos todos los datos de la tabla “Datos” con una instrucción SQL.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">InstruccionSQL = "SELECT Datos.* FROM Datos" <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">C</span><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">aminoConexion = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & ThisWorkbook.Path & "\DBDatos.accdb"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La propiedad <b>Provider</b> (proveedor) establece o devuelve el nombre del proveedor.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La propiedad <b>Source </b>especifica una expresión de cadena que representa al objeto, que en este caso es la dirección de la DB donde tomara los datos.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Conexion.Open ConnectionString:=CaminoConexion<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">ConnectionString</span></b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"> establece o devuelve los datos utilizados para crear una conexión con una fuente de datos.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Establecida la conexión abrimos la tabla donde tenemos los datos.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Datos.Open Source:=InstruccionSQL, ActiveConnection:=Conexion<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">If Datos.EOF = True Then <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">La función <b>EOF</b> devuelve False hasta que se haya llegado al final del archivo.<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 70.8pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">MsgBox "No se encontraron datos"<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Else<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 70.8pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Range("A3").CopyFromRecordset Data:=Datos <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 70.8pt; margin-right: 0cm; margin-top: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">CopyFromRecordset </span></b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">copia el contenido de un objeto <b>Recordset</b> ADO o DAO en una hoja de cálculo…<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 70.8pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Hoja1.Range("A:E").Columns.AutoFit <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 70.8pt; margin-right: 0cm; margin-top: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Esta línea autoajusta las columnas a los datos exportados de la DB<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End If<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Liberamos la memoria de datos.....<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Conexion.Close Set Conexion = Nothing<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Set Datos = Nothing<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Y ya tendríamos los datos listos en Excel para utilizarlos.<o:p></o:p></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0tag:blogger.com,1999:blog-1091239317608127959.post-14211127993765140732011-12-08T16:15:00.000-08:002011-12-10T05:16:37.576-08:00Animación en Excel<div class="MsoNormal" style="line-height: 18.0pt; margin-bottom: 3.75pt; margin-left: 0cm; margin-right: 0cm; margin-top: 3.75pt;"></div><div class="MsoNormal" style="margin-bottom: 3.75pt; margin-left: 0cm; margin-right: 0cm; margin-top: 3.75pt;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Junto a la creación de código VBA para los cálculos matemáticos y financieros, también es posible crear algunas divertidas aplicaciones en Excel VBA, incluyendo juegos y animación. Aunque los programadores profesionales pueden no estar interesados en escribir aplicaciones, merece la pena que probar como un hobby y por satisfacción personal.<o:p></o:p></span></div><br />
<div class="MsoNormal">La a<span class="Apple-style-span" style="font-family: 'Times New Roman', serif; font-size: 16px; line-height: 18px;">nimación se puede lograr cambiando la posición de un objeto continuamente mediante un procedimiento bucle. Dos propiedades o funciones que son necesarios para cambiar las posiciones o las coordenadas del objeto son las propiedades izquierda y superior. La propiedad </span><b style="font-family: 'Times New Roman', serif; font-size: 16px; line-height: 18px;">Left</b><span class="Apple-style-span" style="font-family: 'Times New Roman', serif; font-size: 16px; line-height: 18px;"> especifica la distancia entre el borde izquierdo del objeto en píxeles del borde izquierdo de la pantalla y la propiedad </span><b style="font-family: 'Times New Roman', serif; font-size: 16px; line-height: 18px;">Top</b><span class="Apple-style-span" style="font-family: 'Times New Roman', serif; font-size: 16px; line-height: 18px;"> especifica la distancia del borde superior del objeto de la frontera superior de la pantalla.</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Por ejemplo, el siguiente código hace que el objeto se mueva de izquierda a derecha y luego de vuelta a la izquierda de nuevo en repetidas ocasiones.</span><span lang="EN-US" style="font-size: 12pt; line-height: 115%;"> </span></div><div class="MsoNormal"><span lang="EN-US" style="font-size: 12pt; line-height: 115%;"></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub Animacion1()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">repetir:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">With ActiveSheet.Shapes.Range(Array("1 Picture"))<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">.Left = .Left + 1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">DoEvents<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">If .Left > 200 Then .Left = 1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End With<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">GoTo repetir<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;"><br />
</div><div class="MsoNormal"><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;">Si desea mover el objeto hacia arriba y hacia abajo, cambiar el código anterior por el siguiente:<o:p></o:p></span></div></div><div class="MsoNormal"><br />
</div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">Sub Animacion2()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">repetir:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">With ActiveSheet.Shapes.Range(Array("1 Picture"))<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">.Top = .Top + 1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">DoEvents <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">If .Top > 200 Then .Top = 1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End With<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">GoTo repetir<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">End Sub<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 35.4pt; margin-right: 0cm; margin-top: 0cm;"><span lang="EN-US" style="color: #000066; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></div>Jose Luishttp://www.blogger.com/profile/15675916900093642900noreply@blogger.com0