Sie sind auf Seite 1von 6

Hoja6 - 1

Private Sub Worksheet_Activate()


Sheets("INICIO").ScrollArea = ("A1:A10")
Cambiauser.Show Modeless
End Sub

ThisWorkbook - 1
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call oculta
End Sub
Private Sub Workbook_Open()
Sheets("INICIO").ScrollArea = ("A1:A10")
Call oculta
UserForm1.Show
End Sub

Cambiauser - 1

'Option Explicit
Const GWL_STYLE = -16
Const WS_CAPTION = &HC00000
Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd A
s Long, ByVal nIndex As Long) As Long
Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As
Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare PtrSafe Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWin
dowName As String) As Long
'Posicin del formulario
Dim FormX As Double, FormY As Double
Private Sub CommandButton1_Click()
Call oculta
UserForm1.Show
End Sub
Private Sub CommandButton2_Click()
Call CERRAR
End Sub
Private Sub UserForm_Initialize()
Dim lngWindow As Long, lFrmHdl As Long
lFrmHdl = FindWindowA(vbNullString, Me.Caption)
lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
lngWindow = lngWindow And (Not WS_CAPTION)
Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
Call DrawMenuBar(lFrmHdl)
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single,
ByVal Y As Single)
If Button = 1 Then
FormX = X
FormY = Y
End If
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single,
ByVal Y As Single)
If Button = 1 Then
Me.Left = Me.Left + (X - FormX)
Me.Top = Me.Top + (Y - FormY)
End If
End Sub
Private Sub CloseButton_Click()
Unload Me
End Sub

UserForm1 - 1
'Option Explicit
Const GWL_STYLE = -16
Const WS_CAPTION = &HC00000
Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd A
s Long, ByVal nIndex As Long) As Long
Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As
Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare PtrSafe Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWin
dowName As String) As Long
'Posicin del formulario
Dim FormX As Double, FormY As Double
Private Sub CommandButton1_Click()
Call acceso
End Sub
Private Sub CommandButton2_Click()
Call CERRAR
End Sub

Private Sub UserForm_Initialize()


Dim lngWindow As Long, lFrmHdl As Long
lFrmHdl = FindWindowA(vbNullString, Me.Caption)
lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
lngWindow = lngWindow And (Not WS_CAPTION)
Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
Call DrawMenuBar(lFrmHdl)
TextBoxU = ""
TextBoxC = ""
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single,
ByVal Y As Single)
If Button = 1 Then
FormX = X
FormY = Y
End If
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single,
ByVal Y As Single)
If Button = 1 Then
Me.Left = Me.Left + (X - FormX)
Me.Top = Me.Top + (Y - FormY)
End If
End Sub

Mdulo1 - 1
Sub acceso()
Dim TablaUsuarios As Range
Dim usuario, clave As String
On Error GoTo advr
Sheets("INICIO").Activate
Range("XFC1").Select
Set TablaUsuarios = Range("XFC2:XFD5")
usuario = UserForm1.TextBoxU
clave = UserForm1.TextBoxC
clavecorrecta = Application.WorksheetFunction.VLookup(usuario, TablaUsuarios, 2, False)
If clavecorrecta <> clave Then GoTo advr
If clave = "anax" Then
Sheets("GONIOMETRICA").Visible = -1
Sheets("GONIOMETRICA").Activate
Sheets("Grfico y=ax+bx+c").Visible = -1
ElseIf clave = "pepe" Then
Sheets("SENO").Visible = -1
Sheets("SENO").Activate
ElseIf clave = "rompe" Then
Sheets("Sistema de 3 ecuaciones").Visible = -1
Sheets("Sistema de 3 ecuaciones").Activate
ElseIf clave = "anac" Then
Sheets("Grfico y=ax+b").Visible = -1
Sheets("Grfico y=ax+b").Activate
End If
Unload UserForm1
End
advr:
Ouch = MsgBox("EL USUARIO, LA CLAVE O AMBOS" & Chr(13) _
& "SON ERRONEOS", vbCritical)
End Sub
Sub oculta()
Sheets("GONIOMETRICA").Visible = 2
Sheets("SENO").Visible = 2
Sheets("Sistema de 3 ecuaciones").Visible = 2
Sheets("Grfico y=ax+b").Visible = 2
Sheets("Grfico y=ax+bx+c").Visible = 2
End Sub
Private Sub muestra()
Sheets("GONIOMETRICA").Visible = -1
Sheets("SENO").Visible = -1
Sheets("Sistema de 3 ecuaciones").Visible = -1
Sheets("Grfico y=ax+b").Visible = -1
Sheets("Grfico y=ax+bx+c").Visible = -1
End Sub

Mdulo1 - 2

Sub CERRAR()
SIONO = MsgBox("SEGURO QUE QUIERE SALIR?", vbYesNo)
If SIONO = vbYes Then
Unload UserForm1
ActiveWorkbook.Close
End If
End Sub
Sub lanza_form()
UserForm1.Show
End Sub

Das könnte Ihnen auch gefallen