Академический Документы
Профессиональный Документы
Культура Документы
can Frmatepreiko — 24 Inportrbloguesen colunnas SW rater os deimtasores consecutios cama une slo es ee ‘ras cocones de mpartadién, 5a Qechokitir el reconccininnto de fecha BP" Deshabttr redreccionamientos de cones web 21x!) eee N° Propiedades Valores devueltos 1. WebFormatting Constante Constantes xlWebFormattingNone xlWebFormattingRTF xlWebFormattingAll 2. WebPreFormattedTextToColumns Booleano 3. WebConsecutiveDelimiterAsOne — Booleano 4. WebSingleBlockTextlmport Booleano 5. WebDisableDateRecognition Booleano 6. WebDisableRedirections * Booleano Otras propiedades utilizadas para las consultas Web Connection Cadena de caracteres. URL del origen de datos Web. Ea VBA Excel 2002aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.Capitulo 11 D.Publicacion de paginas Web Es posible crear y publicar una pagina Web a partir de un libro, una hoja de Excel, un grafico, un rango de celdas... Para una pagina Web a partir de Excel, seleccione la opcién Guardar como. pagina Web del mend Archivo y seleccione la opcién Agregar la interactivi- dad. Pulse el botén Publicar para modificar los parametros de publicacién. En VBA, para asociar un elemento de un libro a una pdgina Web, debera crear un objeto PublishObject (utilizando el método Add de la coleccién PublishObjects). Para publicar la pagina Web, debera utilizar a continuaci6n el método Publish del objeto PublishObject. 1. Asociacién de un elemento de libro a una pagina Web Sintaxis PublishObjects.Add(SourceType, FileName, Sheet, Source, HtmlType, DivID, Title) Sdlo los argumentos sourceType y FileName son obligatorios. PublishObjects Expresién que devuelve una coleccién PublishOb- jects. SourceType Tipo de elemento a publicar (xlSourceSheet, Sour- ceRange, xlSourceworkbook, xlSourceChart, xlSour- ceQuery, xlSourcePivotTable...). Sheet Nombre de la hoja de calculo guardada como pagi- na Web. 1314 | VBA Excel 2002aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.© Editions EN| - All rights reserved Internet F. El objeto HyperLink El objeto HyperLink representa un hipervinculo contenido en una hoja de calculo, un rango de celdas 0 un grafico. El objeto Hyperlink pertenece a la coleccién Hyperlinks de los objetos conte- nedores Range, Workbook y Chart. 1. Propiedades Address Cadena de caracteres. Direccidn de la celda con el hipervinculo especifi- cado. EmailSubject Cadena de caracteres. Texto del asunto de! mensaje electrénico del hi- pervinculo especificado (propiedad utilizada con los hipervinculos de los mensajes electrénicos). Name Cadena de caracteres. Nombre del hipervinculo. Range Objeto range. Rango al que esta vinculado hipervinculo. ScreenTip Cadena de caracteres. Texto de ayuda flotante del hipervinculo especifi- cado. Shape Objeto Shape. Forma vinculada al hipervinculo especificado. VBA Excel 2002 Eiaa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.© Editions ENT - All rights reserved Programacion en Windows Ciertos argumentos de procedimientos de DLL pueden aceptar diferentes tipos de datos (algo asi como las Variant), y deben declararse con el tipo Any (ej.: variable As Any). Visual Basic, para este tipo de argumento, considera que se pasa sistematicamente por referencia; si hay que pasarlo por valor, es preciso explicitarlo en la llamada (y no en la declaraci6n) del procedimiento o de la funcién con la mencién Byval. De modo predeterminado, Visual Basic pasa los argumentos por Referencia. C. Lista de funciones de la API de Windows Esta lista incluye las funciones de la API de Windows utilizadas mas habi- tualmente. A continuacién se encontraran ejemplos de uso de algunas de dichas funciones. GetWindowsDirectory() Devuelve el camino completo del directorio de Windows. GetSystemDirectory() Devwuelve el camino completo del directorio del sistema de Windows. GetSystemInfo() Devwuelve toda una serie de datos sobre el sistema. Estos datos se guar- dan en una estructura de tipo SYSTEM_INFO. GetActiveWindow() Devuelve el handle de la ventana activa. VBA Excel 2002 327aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.Capitulo 12 MatchTextExactly Indica si la busqueda especificada debe centrarse sdélo en los archivos que contengan exactamente la palabra o frase especificados, distinguien- do maytisculas de mintisculas. SearchSubFolders Indica si la biisqueda incluye todas las subcarpetas de la carpeta especi- ficada. TextOrProperty Devuelve o define la palabra o frase a buscar en el cuerpo de texto o en las propiedades del archivo. 2. Colecciones FoundFiles Devuelve la coleccién de objetos FoundFile que representa los archivos encontrados en el transcurso de una busqueda. PropertyTests Devuelve la coleccién de objetos PropertyTest que representa todos los criterios de busqueda para una busqueda de archivos. SearchFolders Devuelve una coleccién de objetos SearchForlder que representa todas las carpetas de busqueda. El VBA Excel 2002aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.© Editions EN! - All rights reserved Cédigo de una_miniaplicacion Al abrir el libro, la ventana de Excel obtenida es la siguiente: : ne rozolt Excel - GestPresunuesto.ais 1G) Fresupuesto lentes Sar APLICACION GESTION DE PRESUPUESTOS [\Gestién de presupuestos // ze ‘TuenarnS, oft Ut AY Nut Z 2. Cédigo VBA Option Explicit Dim MatMenu() As String Private Sub Workbook_Act ivate () Dim omd As ComnandBar * Qculta las barras de comandos (salvo la barra de ment) ‘ y las guarda en una matriz para restaurarlas bei ReDim MatMenu (30) For Each cmd In Application.ConmandBars Babes VBA Excel 2002 | 341]aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.© Editions EN! - All rights reserved Cédigo de una miniaplicacion Nombre del control Descripcién 1. cboClients Cuadro de lista desplegable modificable 2. cboOpe Cuadro de lista desplegable modificable con operadores de comparacién (>= 0 <=) 3. txtFecha Cuadro de texto 4. cmdRech Botén de comando 5. cmdSuppr Botén de comando 6. cmdOuvrir Botén de comando 7. \IstPresupuesto Cuadro de lista desplegable 3. Cédigo VBA Option Explicit Private Sub UserForm Initialize() * Operador para el campo Fecha cboOpe AddItem ": cboOpe AddItem " ‘ Permite seleccionar varios presupuestos IstPresupuesto.Multiselect = fmMultiSelectmultL ‘ Muestza los clientes en la lista desplegable Lista Clientes ("BuscaPresupuesto") End Sub Private Sub txtFecha_Beforelpdate _ (ByVal Cancel As MSForms.ReturnBoolean) * Controla la fecha introducida If Not IsDate (txtFecha) Then MsgBox "Escriba una fecha en el formato DD/MM/AAAA", _ vbExclamation End If End Sub VBA Excel 2002 | 345]aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.© Editions EN! - All rights reserved Cédigo de una miniaplicaci6n whee txtFecha = Format (txtFecha, "“DD/MM/YYYY") End If End sub Private Sub CmdCrear_Click() Dim wbk As Workbook Dim wbkName As String Dim £s0 As Object * Controla los datos introducidos If cboCliente = "* Or txtFecha = "" Then MsgBox “Cliente y fecha obligatorios", vb&xclamation Exit Sub End If ' Cierra los libros (salvo ThisWorkbook) For Each wbk In Workbooks If wbk.Name <> ThisWorkbook.Name Then wbk. Close End If Next wbk ' Abre un nuevo libro basado en el modelo Presupuesto.xlt Set wbk = Workbooks.Add(Template:=strfolder & "Presupuesto.xlt") * Verifies que el libro no existe ya wbkName = strFolder £ choCliente & "\" s Right (txtFecha, 4) & _ Mid(txtFecha, 4, 2) @ Left (txtFecha, 2) & ".xls" If Dix (wbkName) <> "" Then MsgBox "El libro " 6 wbkName & " ya existe", vbExclamation Exit Sub End If ‘Crea el subdirectorio del cliente si no existe If Dir(strFolder & cboCliente, vbDirectory) = "" Then Set feo = Createdbject ("Scripting.FileSystomObject") fso.createfolder (strFolder § cboCliente) End If "Guarda el libro en ese directorio wbkName = Right (txtFecha, 4) & Mid(txtFecha, & Left (txtFecha, 2) & ".xls" wbk.SaveAs strFolder & choCliente & "\" & wbkName 2) VBA Excel 2002 fea!aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.© Anexos A. Lista de instrucciones .. 2... eee ee eee 359 1. Fecha Hora/Matematicas 359 2. Declaracion . . 359 3. Error 22. + 362 @. OACRING ew a ee eR wa Be Ee OR 362 5. Estructuracion . . . 364 6. Sistema... . 366 7. 366 Lista de funciones. 2... 2 2 ee ee 367 Conversiones 2... ee 368 Cadenas de caracteres . . awe Va Rae ee we 370 Matematicas . . Financieras ONO PYNne Fecha y hora Archivos, Sistema . 2.6... eee eee ee 380 Verificaciones de variables... 2. - 1. eee ee 382 Interaccion 6. ee 383aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.Anexos. Type Define un tipo de datos definido por el usuario. 3. Error Error Simula la aparicién de un error. On Error Activa una rutina de gestién de error y especifica su ubicacién dentro de un procedimiento. Permite también desactivar una rutina de gestién de error. Resume Retoma la ejecucién del cédigo cuando termina una rutina de gestién de error. 4. Archivo Close Termina las operaciones de Entrada/Salida sobre un archivo abierto me- diante la instruccién Open. FileCopy Copia un archivo, Get Lee los datos de un archivo de disco abierto y los coloca en una varia- ble. 1362 | VBA Excel. 2002.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.Anexos String, StringS Crea una cadena constituida por un caracter repetido por la longitud especificada. StrReverse Devuelve una cadena con caracteres cuyo orden se ha invertido respecto auna cadena dada. Trim, Trim$ Devuelve una copia de una cadena suprimiendo los espacios de la izquierda y de la derecha. UCase, UCase$ Devuelve una cadena cuyos caracteres se han convertido a mayusculas. Ejemplo Procedimiento para calcular un cédigo de identificacién de las mujeres listadas en la hoja siguiente: lidentific| Apellido | Segundo | Nombre | Fecha de | Fecha de | Estado |_ador apellido nacimiento| boda civil Ramirez Cristina |04/06/58 Soltera Duran Gomez [Veronica [24/01/60 15/02/87 _|Casada Poncela__|Garcia Claudia |16/10/62 [22/07/89 __|Casada Tizon Natalia 25/02/65 | Soltera Sub CAlculoldentificador () For I= 2 To 5 ‘1a parte del cédigo cifra 2 seguida de las tres las letras ‘del segundo apellido Cédigo 2 & UCase (Left (Cells(I, 3),3)) "2a parte del cédigo: diferent segin si las mje: ‘casadas o no If Cells(t, 7) = “Casada" Then ee EZ VBA Excel 2002aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.Anexos en MsgBox “Acabando a las 17h30, faltan " & Resto & _ "horas de trabajo" “Calculo y presentacién del ultimo dia del mes en curso Final - DateSerial (Year (Now), Month(Now) + 1, 1)-1 MsgBox “el Gltimo dia del mes en curso es " & Final ‘Presentacién del nimero del dia de la semana de esta fecha MsgBox "Hoy sera un " & Weekday(Final) & _ “ésimo dia de la semana” End Sub 6. Archivos, Sistema CurDir, CurDir$ Devuelve el camino de acceso en curso. i$ Devuelve el nombre de un archivo, de un directorio o de una carpeta que corresponde a un modelo especificado o a un atributo de archivo, o devuelve el nombre de volumen de una unidad. EOF Devuelve un valor que indica si se ha alcanzado el fin de un archivo. FileAttr Devuelve datos sobre el modo del archivo o el manejador del archivo del sistema operativo relativo a un archivo abierto mediante la instruccién Open. FileDateTime Devuelve la fecha y hora de la creacién o de fa ultima modificacién de un archivo. Dir, FileLen Devuelve el tamafio de un archivo en bytes. 1380 | VBA Excel 2002aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.Anexos Choose Selecciona y devuelve un valor a partir de una lista de argumentos. DoEvents Detiene momentaneamente la ejecucién para que el sistema operativo pueda tratar otros sucesos. Environ Devuelve el valor asociado a una variable de entorno del sistema opera- tivo. GetAllSettings Devuelve una lista de claves y sus valores respectivos (creados en su origen mediante la instruccién SaveSetting), que figuran en una entrada de aplicacién de la base del registro de Windows. GetSetting Devuelve un valor de clave de una entrada de aplicacién de la base del registro de Windows. lif Devuelve uno u otro de dos argumentos segiin la evaluacién de una expresion. Spe Funcién utilizada con la instrucci6n Print # 0 el método Print para posicionar la salida. Switch Evalua una lista de expresiones y devuelve un valor o una expresién asociados a la primera expresidn de fa lista que tiene como valor True. Tab Funcidn utilizada con la instrucci6n Print #0 el método Print para posicionar la salida. 1386 | VBA Excel 2002aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.indice ODBCErtors, 87 OLEDBErrors, 87 OLEObjects, 294 RecentFiles, 87 SmartTagRecognizers, 87 Smarttags, 147 UsedObjects, 87 Watches, 87 Windows, 87, 128 Workbooks, 87 WorkSheets, 87, 128 Coleccién Charts suceso, 245 COMAddiIns - colecci6n, 86 Comentarios, 78 CommandBars, 224 CommandBars - coleccién, 86 Comments - coleccién, 146 Complemento automatico de instrucciones, 22, 95 Condiciones If... Then, 63 If... Then... Else... End If, 64 If... Then... Elself..., 65 If... Then... End If, 63 Select Case, 66 Véase también Estructuras de decisién Constantes, 60, 80, 102 de color, 388 de fecha, 389 de teclas de funcién, 390 de teclas del teclado, 389 1394 | VBA Excel 2002aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.Indice tipografias, 24 Enlaces de Excel, 296 ErrorCheckingOptions - objeto, 85 Errores, 258 de compilacién, 259 de ejecucién, 260 de sintaxis, 258 depuracién, 261 Error (funci6n), 267 Error (instruccién), 267 gestion, 264 On Error, 264 Estructuras de decision, 62 condicién, 63 instruccién IF, 63 instruccién Select Case, 66 Estructuras en bucle, 67 instrucci6n Do...Loop, 68 instruccién For Each...Next, 71 instrucci6n For...Next, 70 instruccién While...Wend, 69 Examinador de objetos, 101 Exit Do, 73 Exit For, 73 Explorador de objetos, 23 Explorador de proyeto, 22 1396 | VBA Excel 2002aa You have either reached a page that is unavailable for viewing or reached your viewing limit for this book.Reéursos Informaticos Redes, sistemas, programacion, SGBDR, tecnologias Internet 0 intranet, informatica industrial... Los ambitos que abarca la informatica técnica siguen la evolucién de las tecnologias, siendo cada dia mas variados y complejos. Esta evolucién amplia los campos de aprendizaje de los nuevos expertos e impone a los profesionales una continua adaptacion de sus conocimientos. Redactados por formadores profesionales y consultores, los libros de la coleccién Recursos informaticos le aportan una ayuda eficaz para descubrir y aplicar diferentes técnicas. La presentacion de los conceptos basicos, de numerosos ejemplos y los consejos de expertos garantizan la calidad y riqueza de cada uno de estos libros. VBA Excel 2002 Programar con Excel: Macros y lenguaje VBA Michéle AMELOT Simple, practica y completa a la vez, esta obra A dirigida sesares a los usuarios de Excel 0 a los desarrolladores que quieran crear aplicaciones de hoja de cdlculo fiables, potentes y de facil uso, Ademas de los elementos basicos del lenguaje VBA este profundo conocin idades de usuarios y aprendizae y practica de la p guaje VBA (estructura del lenguaje y conceptos de programacién orientada a objetos), se ensena a automatizar tratamientos, a disefar formularios (UserForm) personalizados, a administra controles ActiveX, a crear mentis y barras de ISBN: 2-7460-1643-5 herramientas, a controlar las demds aplicaciones de Office XP mediante la tecnologia Automation, a importar datos jentes de sitios Web y a utilizar las API de Windows. I | lh l | i 7 9 "782746" 016439 nas de los numerosos ejemplos proporcionados en esta el dltimo capitulo ensefa paso a paso a crear una Precio: 26.95 € nen Excel ST eee eee eB ee) eo ue ee eee)