FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV 2024
→
WD: Protect an Excel file with Passord
WD: Protect an Excel file with Passord
Débuté par Gianni Spano, 21 oct. 2010 19:43 - 2 réponses
Connectez-vous…
Gianni Spano
#1
Posté le 21 octobre 2010 - 19:43
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
Signaler
0
0
Paulo Oliveira
#2
Posté le 22 octobre 2010 - 01:58
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
Signaler
0
0
Gianni Spano
#3
Posté le 22 octobre 2010 - 09:28
Thanks Paulo
I will try your solution tomorrow morning..
Thanks again for your support..
:spos:
Gianni
Signaler
0
0
→ Revenir à WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte