Skip to content

Instantly share code, notes, and snippets.

View tombrad's full-sized avatar

Tomas Bradanovic tombrad

View GitHub Profile
@tombrad
tombrad / gist:4726998
Created February 6, 2013 23:47
Curso VBA-6
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1.Text = UCase(TextBox1.Text)
End Sub
@tombrad
tombrad / gist:4727007
Created February 6, 2013 23:48
Curso VBA-7
Private Sub CommandButton1_Click()
With Selection
. Font.Size = Val(10)
. ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
. TypeParagraph
. Font.Name = “arial black”
. ParagraphFormat.Alignment = wdAlignParagraphCenter
. TypeText Text:=vbTab & “Programa de Prueba”
. ParagraphFormat.Alignment = wdAlignParagraphLeft
. TypeParagraph
@tombrad
tombrad / gist:4727041
Created February 6, 2013 23:52
Curso VBA-8
Curso VBA-8Sub Macro2()
‘ Macro2 Macro
‘ Macro grabada el 24-12-98 por TOMAS BRADANOVIC
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
@tombrad
tombrad / gist:4727049
Created February 6, 2013 23:54
Curso VBA-9
Application.PrintOut FileName:=”Permiso.doc”, Range:=wdPrintCurrentPage, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:=”", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
Unload UserForm1
@tombrad
tombrad / gist:4868211
Created February 13, 2013 02:06
Curso VBA-10
Sub formulario1()
‘ formulario1 Macro
‘ Macro creada el 26/07/2010 por INTEL
UserForm1.show
End Sub
@tombrad
tombrad / gist:4880005
Created February 13, 2013 02:14
Curso VBA-11
‘ Programa para llenar automáticamente un formulario en word
‘ Lo que está escrito con comilla simple son solo comentarios para explicar el programas, pueden omitirse
‘ With… EndWith sirve para no tener que repetir la misma instrucción en cada línea, en este caso Selection
With Selection
.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle ‘Coloca espacio de líneas en “espacio simple”
.TypeParagraph ‘Pasa a linea siguiente
.TypeParagraph ‘Pasa a linea siguiente
.Font.Bold = True ‘Coloca negrita
.TypeParagraph ‘Pasa a linea siguiente
@tombrad
tombrad / gist:4942167
Created February 13, 2013 04:03
Prototipos VBA-1
Private Sub CommandButton1_Click()
indice = Hoja1.Cells(1, 1)
If indice = "" Then
indice = 1
Hoja1.Cells(1, 1) = indice
End If
indice = indice + 1
Hoja1.Cells(1, 1) = indice
Hoja1.Cells(indice, 1) = TextBox1.Text
Hoja1.Cells(indice, 2) = TextBox2.Text
@tombrad
tombrad / gist:4942181
Created February 13, 2013 04:05
Prototipos VBA-2-1
Private Sub ComboNombre_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Rem al escoger un item del combobox hace lo siguiente
Rem coloca el costo en textbox1
TextBox1.Text = Hoja1.Cells(2, 2)
Rem coloca el precio de venta (lista) en textbox2
TextBox2.Text = Hoja1.Cells(2, 3)
End Sub
@tombrad
tombrad / gist:4942184
Created February 13, 2013 04:06
Prototipos VBA-2-2
Private Sub CommandButton1_Click()
Rem para agregar un nuevo articulo
Rem se carga userform2
Load UserForm2
Rem se muestra userforrm2
UserForm2.Show
End Sub
@tombrad
tombrad / gist:4942187
Created February 13, 2013 04:07
Prototipos VBA-2-3
Private Sub CommandButton2_Click()
Rem al ingresar la venta
Rem el saldo esta en hoja1.cells de la linea de combo que elegimos
Rem que en la hoja exel seria la posicion combonombre.listindex + 1
Rem recordar el formato Hoja1.Cells(linea,columna)
Rem luego toma el valor (cantidad) almacenado en esa celda y le resta el valor de textbox3.text
Hoja1.Cells(ComboNombre.ListIndex + 1, 2) = Hoja1.Cells(ComboNombre.ListIndex + 1, 2) - TextBox3.Text
Rem con eso deja la cantidad rebajada
Rem luego limpia los textbox combo y pone el foco en combonombre
TextBox1.Text = ""