Good afternoon to everyone.
I'm facing a trouble, when I try to refresh all via vba. I have a main table stored in a workbook, from this table depends several workbooks to update their table contents. When the "source" workbook remains without protection the ThisWorkbook.RefreshAll works fine, the trouble starts when I put a password to protect the source workbook, until now I try this:
Please forgive me due the simplicity in this code, but I'm not an expert in .vba
As soon the workbook starts I receive a compile error: Type mismatch
Any help with this issue, will be really appreciated, I know, maybe for giants like Skip this is a piece of cake, but I feel my self like a dog trying to catch his own tail.
Best regards and have a great day.
I'm facing a trouble, when I try to refresh all via vba. I have a main table stored in a workbook, from this table depends several workbooks to update their table contents. When the "source" workbook remains without protection the ThisWorkbook.RefreshAll works fine, the trouble starts when I put a password to protect the source workbook, until now I try this:
Code:
Private Sub Workbook_Open()
Dim WB As Workbook
Dim pw As String
Const DateEnd As Date = "11/15/2020"
If Date > DateEnd Then
MsgBox ("Este archivo no se puede ser usado sin licencia o autorizacion del autor")
ActiveWorkbook.Close SaveChanges:=False
End If
Set WB = "C:\\Users\Capacitacion\Documents\RootOfficeTemplates\Repositorio\Bases\MainDataSource.xlsx"
pw = "VLF800913"
WB.Unprotect (pw)
ThisWorkbook.RefreshAll
'
Sheets("Mach1").Visible = True
Sheets("Registro").Visible = xlSheetVeryHidden
Sheets("Empleados").Visible = xlSheetVeryHidden
Sheets("Diap1").Visible = xlSheetVeryHidden
Sheets("Diap2").Visible = xlSheetVeryHidden
Sheets("Diap3").Visible = xlSheetVeryHidden
Sheets("Diap4").Visible = xlSheetVeryHidden
Sheets("Diap5").Visible = xlSheetVeryHidden
Sheets("Diap6").Visible = xlSheetVeryHidden
Sheets("Diap7").Visible = xlSheetVeryHidden
Sheets("Diap8").Visible = xlSheetVeryHidden
Sheets("Diap9").Visible = xlSheetVeryHidden
Sheets("Diap10").Visible = xlSheetVeryHidden
Sheets("Evaluacion").Visible = xlSheetVeryHidden
Sheets("Registro").Visible = True
Sheets("Registro").Select
Range("j10").Select
Sheets("Mach1").Visible = False
'
Sheets("Registro").Select
Range("j10").Select
'If Range("b1").Value = "Bloqueado" Then
'Dim answer As Integer
'answer = MsgBox("Desea continuar? Le sera requerida una contraseña", vbYesNo + vbQuestion, "Desbloqueador de curso")
'If answer = vbYes Then
'UserForm2.Show
'Else
' ActiveWorkbook.Close SaveChanges:=False
' End If
'End If
MsgBox ("Por favor digite su numero de empleado presione enter y enseguida presione al mismo tiempo Ctrl+Shift+V, esto para revisar si Usted ya ha iniciado alguno de los modulos y recuperar su informacion")
MsgBox ("Tenga en cuenta que al abrir el nuevo libro le sera requerido que haga lo mismo, por favor ignore la instruccion y seleccione directamente el formulario de seleccion de modulo")
'UserForm1.Show
'
'Bienvenida.Show
End Sub
Please forgive me due the simplicity in this code, but I'm not an expert in .vba
As soon the workbook starts I receive a compile error: Type mismatch
Any help with this issue, will be really appreciated, I know, maybe for giants like Skip this is a piece of cake, but I feel my self like a dog trying to catch his own tail.
Best regards and have a great day.