domingo, 1 de febrero de 2009

Construcciones With End With

Construcciones With - End With

nos permitira realizar varias operaciones con un objeto sin la necesidad
de referenciarlo varias veces.

Por ejemplo..

En este ejemplo se observa la referencia Selection.Font hasta 3 veces..pero se puede mejorar..

verifique Las siguientes macros y quedara totalmente claro

Sub sinWITHENDW() 'Macro1


Selection.Font.Color = 255 'color fuente

Selection.Font.Bold = True 'negrita

Selection.Font.Italic = True 'itali

End Sub



Sub conWithEndWith() 'Macro2


With Selection.Font


.Color = 255 'color fuente

.Bold = True 'negrita

.Italic = True 'itali

End With


End Sub