GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEV
,
WEBDEV
e
WINDEV Mobile
Inicio
|
Mensagens recentes
|
Conecte-se...
|
Disconnect
|
Português
Inicio
→
WINDEV 2024
→
WD: Protect an Excel file with Passord
WD: Protect an Excel file with Passord
Iniciado por Gianni Spano, out., 21 2010 7:43 PM - 2 respostas
Conecte-se…
Gianni Spano
#1
Publicado em outubro, 21 2010 - 7:43 PM
Hello
I have over 120 excel files to protect with the same password.
These files are created with WD, reading each record (one for every excel file)
from a customer file and because the context of each file is private, i need to secure these files with a password. Every time a user try to open a file, it must prompt to input a known password.
Does someone have a solution to set a password during the step
when i generate the excel file?
Below there is a little solution i have found in Visual Basic:
Sub ProtectFile()
Dim nombre As Integer
nombre = ActiveWorkbook.Sheets.Count
Application.ScreenUpdating = False
For i = 1 To nombre
Worksheets(i).Protect , password:="blabla"
Next i
End Sub
Sub UnProtetFile()
' unprotect all sheets
Dim nombre As Integer
nombre = ActiveWorkbook.Sheets.Count
Application.ScreenUpdating = False
For i = 1 To nombre
Worksheets(i).Unprotect , password:="blabla"
Next i
TIA
Gianni
Denunciar
0
0
Paulo Oliveira
#2
Publicado em outubro, 22 2010 - 1:58 AM
I didn't test it but this code and your explanation don't seems to match.
NOTE: the code that I am suggesting is untested. I don't have access to WinDev, i'm at home (today at least i leave the office at a decent hour).
to translate this code to Wlanguage use something like this:
m_xExcel is object OLE dynamic
m_xExcel=new object OLE "Excel.Application"
m_xExcel>>Workbooks>>Open("c:\myfiles\test.xls")
wint is int
wi is int
wint = m_xExcel>>ActiveWorkbook>>Sheets>>Count
FOR wi = 1 TO wint
m_xExcel>>Sheets( wi)>>Protect("aaa")
END
m_xExcel>>ActiveWorkbook>>Saveas("c:\myfiles\test_1.xls")
m_xExcel>>ActiveWorkbook>>close(False)
m_xExcel>>Quit()
delete m_xExcel
to do what you are asking use something like this:
m_xExcel is object OLE dynamic
m_xExcel=new object OLE "Excel.Application"
m_xExcel>>Workbooks>>Open("c:\myfiles\test.xls")
m_xExcel>>ActiveWorkbook>>Saveas("c:\myfiles\test_1.xls",*,"aaa")
m_xExcel>>ActiveWorkbook>>close(False)
m_xExcel>>Quit()
delete m_xExcel
Denunciar
0
0
Gianni Spano
#3
Publicado em outubro, 22 2010 - 9:28 AM
Thanks Paulo
I will try your solution tomorrow morning..
Thanks again for your support..
:spos:
Gianni
Denunciar
0
0
→ Voltar para WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (versões anteriores)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Tipo de Pesquisa
Apenas tópicos
Todas as mensagens
Período de pesquisa
Qualquer momento
Última hora
Últimas 24 horas
Semana passada
Mês passado
Ano passado
Cancelar
Pré-visualização da sua mensagem
Adicionar imagem
Importar uma imagem de uma URL
Enviar uma imagem a partir do seu disco
Deixe um ficheiro ou clique em "Procurar ..."
ou
Cancelar
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Texto