Anexo macro. consiste en un un userform con dos botones uno para habilitar la captura por parte del usuario ( lo hice así porque luego podían solo abrir y no capturar nada), el otro botón que inserta la información capturada y con esos datos manda un correo, en el primer botón dejo de compartir y proteger el libro y al finalizar el segundo protege y comparte nuevamente adicional tengo un botón de salir pero esto solo cierra el formulario si ya se habilito la opción insertar también protege y comparte antes de salir si no se ha habilitado unicamente cierra el formulario en ambas acciones que desprotege libro y vuelve a proteger es donde ya no me pide password si lo hago manualmente.
Private Sub CommandButton3_Click()
CommandButton2.Visible = True
CommandButton4.Visible = False
Application.DisplayAlerts = False
If ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.ExclusiveAccess
End If
Application.DisplayAlerts = True
ActiveSheet.Unprotect "DP2012"
TextBox1.Enabled = True
TextBox5.Enabled = False
TextBox5 = Hoja1.Range("A1").Value + 1
Label1.Visible = True
DTPicker1.Visible = True
DTPicker1.Enabled = True
Label2.Visible = True
TextBox1.Visible = True
Label5.Visible = True
ComboBox1.Visible = True
ComboBox1.Enabled = True
ComboBox2.Visible = True
ComboBox2.Enabled = True
ComboBox3.Enabled = True
CheckBox1.Enabled = True
Label7.Visible = True
TextBox4.Visible = True
Label6.Visible = True
TextBox3.Visible = True
TextBox3.Enabled = True
Label4.Visible = True
DTPicker1.Visible = True
DTPicker2.Visible = True
DTPicker2.Enabled = True
TextBox2.Enabled = True
CommandButton3.Visible = False
CommandButton1.Visible = True
Label10.Visible = True
ComboBox2.AddItem "GP"
ComboBox2.AddItem "GC"
ComboBox2.AddItem "PR"
ComboBox2.AddItem "DDP"
ComboBox2.AddItem "GMI"
ComboBox2.AddItem "GA"
ComboBox2.AddItem "GCIA"
ComboBox2.AddItem "DP"
ComboBox3.AddItem "Inicio"
ComboBox3.AddItem "Clientes-Calidad"
ComboBox3.AddItem "Seguridad"
ComboBox3.AddItem "Gestión de Personal"
ComboBox3.AddItem "Proveedores"
ComboBox3.AddItem "Proyectos"
ComboBox3.AddItem "Innovación y Creatividad"
ComboBox3.AddItem "Administración"
ComboBox3.AddItem "Junta de Area"
ComboBox3.AddItem "Capitanes"
ComboBox3.AddItem "Revisión Gerencial"
DTPicker1.Value = Null
DTPicker2.Value = Null
End Sub
Private Sub CommandButton1_Click()
If DTPicker1.CheckBox = False Then
DTPicker1.CheckBox = True
Else
DTPicker2.CheckBox = False
DTPicker2.CheckBox = True
End If
TextBox5.Enabled = True
Range("B11").Select
Selection.EntireRow.Insert
DTPicker1 = Empty
DTPicker2 = Empty
TextBox1 = Empty
TextBox2 = Empty
TextBox3 = Empty
TextBox4 = Empty
TextBox5 = Empty
ComboBox1 = Empty
ComboBox2 = Empty
TextBox5.SetFocus
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox5.Enabled = False
ComboBox1.Enabled = False
ComboBox2.Enabled = False
ComboBox3.Enabled = False
CheckBox1.Enabled = False
DTPicker1.Enabled = False
DTPicker2.Enabled = False
CommandButton3.Visible = True
Range("A10").Select
Selection.Copy
Range("A11:A12").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=-3
Range("P10:S10").Select
Application.CutCopyMode = False
Selection.Copy
Range("P11:S12").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("B9").Select
ActiveSheet.Range("B9:I12").Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = "Revísalo en: CRITERIO 4\4.1 UTILIZACIÓN Y ANÁLISIS DE LA INFORMACIÓN\Reporteador de Compromisos 2012"
.Item.To = Range("K12")
.Item.Subject = Range("S12")
.Item.Send
End With
Sheets("Tabla").Select
Range("D6").Select
ActiveSheet.PivotTables("Tabla dinámica1").PivotCache.Refresh
Sheets("PRINCIPAL").Select
Range("B9").Select
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.FullName, _
accessMode:=xlShared
Application.DisplayAlerts = True
ActiveSheet.Protect "DP2012"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True
CommandButton1.Visible = False
CommandButton2.Visible = False
CommandButton4.Visible = True
End Sub