- Este tópico contém 4 respostas, 2 utilizadores e foi actualizado pela última vez há 11 anos, 8 meses por jorgerod.
-
AutorArtigos
-
-
9 de Agosto de 2012 às 16:47 #1125AnónimoInactivo
boa tarde jorge!
esse artigo que vc postou no site me ajudou bastante, porém tentei adaptar a uma programa vba e não consegui, vc poderia me ajudar?
segue programação para proteger e desproteger planilha do excel, porém a senha aparece os caracteres e eu gostaria que aparecesse mascarada (****). entendeu?
sub proteger_1()
application.screenupdating = false
sbdesproteger = “digite uma senha para proteger o arquivo.” & vbcrlf _
sbtitulo = “wagner goularte”
for each wsplan in activeworkbook.worksheets
if wsplan.protectcontents = true thendesproteger_1
exit sub
end if
next wsplansbproteger = application.inputbox(prompt:=sbdesproteger, title:=sbtitulo, default:=””, type:=2)
if sbproteger = ok then
if sbproteger = “” then
msgbox “digite uma senha !!!”
sbproteger = application.inputbox(prompt:=sbdesproteger, title:=sbtitulo, default:=””, type:=2)
end if
elseif sbproteger = cancel then
exit sub
end ifif sbproteger = vbcancel then
exit sub
end ifdo while sbproteger1 sbproteger
msgbox “digite novamente a senha !!!”
sbproteger1 = application.inputbox(prompt:=sbdesproteger, title:=sbtitulo, default:=””, type:=2)if sbproteger1 = cancel then
msgbox “arquivo não foi protegido!!!” & vbcrlf _
, vbcritical, “wagner goularte”
exit sub
end ifif sbproteger1 = vbcancel then
msgbox “arquivo não foi protegido!!!” & vbcrlf _
, vbcritical, “wagner goularte”
exit sub
end ifloop
if sbproteger1 = sbproteger then
for each wsplan in activeworkbook.worksheets
wsplan.protect password:=sbproteger, drawingobjects:=true, contents:=true, scenarios:=true, _
allowfiltering:=true, allowformattingcells:=true, allowformattingcolumns:=true, _
allowformattingrows:=true, allowinsertingcolumns:=true, allowinsertingrows:=true, _
allowinsertinghyperlinks:=true, allowdeletingcolumns:=true, allowdeletingrows:=true, _
allowsorting:=true, allowusingpivottables:=truenext wsplan
msgbox “arquivo protegido com sucesso!!!”
sbproteger = empty
end if
endapplication.screenupdating = true
end if
msgbox “arquivo não foi protegido!!!” & vbcrlf _
, vbcritical, “wagner goularte”end sub
sub desproteger_1()application.screenupdating = false
‘ desprotege
on error resume next
sbdesproteger = “digite a senha para remover a proteção do arquivo.”sbtitulo = “wagner goularte”
sbproteger = application.inputbox(prompt:=sbdesproteger, title:=sbtitulo, default:=””, type:=2)
if sbproteger = cancel then
exit sub
end ifif sbproteger = vbcancel then
msgbox “arquivo não foi desprotegido!!!” & vbcrlf _
, vbcritical, “wagner goularte”
exit sub
end iffor each wsplan in activeworkbook.worksheets
if wsplan.protectcontents = false then goto proxima
wsplan.unprotect password:=sbproteger
if err.number 0 then
msgbox “senha incorreta!!!”, vbcritical, “wagner goularte”
exit sub
end if
proxima:
next wsplanapplication.screenupdating = true
end sub
aguardo um retorno!
att.
wagner goularte -
9 de Agosto de 2012 às 20:57 #1902jorgerodAdministrador
wagner,
não podes usar inputbox. tens que utilizar o inputboxdk, como é referido no post e tens que colocar num módulo o código do daniel klann.
fica bem.
-
9 de Agosto de 2012 às 23:44 #1903AnónimoInactivo
jorge,
eu fiz isso. criei um módulo conforme código do daniel, mas não deu certo, ao substituir o inputbox por inputboxdk nem funcionou a macro de proteger as planilhas.
aguardo resposta.
att.
wagner goularte -
10 de Agosto de 2012 às 0:30 #1904jorgerodAdministrador
vê a planilha que te envio, com o que pretendes e a funcionar, acho eu 🙂
fica bem e diz qq coisa, ok?
Wagner_Protege_Desprotege.zip -
10 de Agosto de 2012 às 11:31 #1126AnónimoInactivo
bom dia jorge !!!
muito obrigado!!! mais uma vez ….
vc é o cara ….
agradeço muito a ajuda que constantemente tem me dado.
abração !!! bom fds !!!
-
-
AutorArtigos
- Tem de iniciar sessão para responder a este tópico.