2
Hello, I have a spreadsheet matrix that will enter in other thousands of smaller spreadsheets, will save in another extension, will put a code inside this and wanted it to block the vba project of these smaller spreadsheets, I’m trying to use Sendkeys for this, but this inefficient.
Sub entrando_no_padrão()
Application.DisplayAlerts = False
Dim fld As Object
Dim fld2 As Object
Dim fld3 As Object
Dim fld4 As Object
Dim fld5 As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set fso2 = CreateObject("Scripting.FileSystemObject")
Set fso3 = CreateObject("Scripting.FileSystemObject")
Set fso4 = CreateObject("Scripting.FileSystemObject")
Set fso5 = CreateObject("Scripting.FileSystemObject")
Dim ver_num As Integer
ver_num = 0
Set fld = fso.GetFolder("C:\1")
n = 1
y = 1
For Each fld In fld.SubFolders
If fld <> "ESSE_NOME_NÃO_ENTRA" Then
Set fld2 = fso2.GetFolder("C:\1\" & fld.Name)
For Each fld2 In fld2.SubFolders
If Len(Dir("C:\1\" & fld.Name & "\" & fld2.Name & "\PCP- Planos de controle", vbDirectory) & "") > 0 Then
Set fld3 = fso3.GetFolder("C:\1\" & fld.Name & "\" & fld2.Name & "\PCP- Planos de controle")
For Each fld3 In fld3.Files
Call PADRONIZAR(fld.Name, fld2.Name, fld3.Name)
SendKeys "%f" & "p" & "^{TAB}" & "{+}" & "{TAB}" & "34670920" & "{TAB}" & "34670920" & "{TAB}" & "~" & "%{F4}"
Next fld3
End If
If Len(Dir("C:\1\" & fld.Name & "\" & fld2.Name & "\PEP - Plano de embalagem", vbDirectory) & "") > 0 Then
Set fld4 = fso4.GetFolder("C:\1\" & fld.Name & "\" & fld2.Name & "\PEP - Plano de embalagem")
For Each fld4 In fld4.Files
Call PADRONIZAR(fld.Name, fld2.Name, fld4.Name)
SendKeys "%f" & "p" & "^{TAB}" & "{+}" & "{TAB}" & "34670920" & "{TAB}" & "34670920" & "{TAB}" & "~" & "%{F4}"
Next fld4
End If
If Len(Dir("C:\1\" & fld.Name & "\" & fld2.Name & "\FIT - Ficha de Instrução de Trabalho", vbDirectory) & "") > 0 Then
Set fld5 = fso5.GetFolder("C:\1\" & fld.Name & "\" & fld2.Name & "\FIT - Ficha de Instrução de Trabalho")
For Each fld5 In fld5.Files
Call PADRONIZAR(fld.Name, fld2.Name, fld5.Name)
SendKeys "%f" & "p" & "^{TAB}" & "{+}" & "{TAB}" & "34670920" & "{TAB}" & "34670920" & "{TAB}" & "~" & "%{F4}"
Next fld5
End If
Next fld2
End If
Next fld
If x <> x Then
final:
Open "\\caminha\para\abrir\um\txt" For Append As #2
Print #2, fld2.Path
Close #2
End If
Application.DisplayAlerts = True
End Sub
That’s it, for now.
I answered your question but I was in doubt if you want to block the visualization of VBA in the spreadsheet or generated by it.
– Marco
Those generated by the matrix
– Leandro Felipe Moreira
Via
VBA
you cannot define a code to protect the "VBA
" of the smaller spreadsheets as theVBAProject
does not expose the password to be set via code, this would have to be done via Sendkeys– Marco
I didn’t see any code generating spreadsheets in this section you posted. It would be this
PADRONIZAR
?– Marco
"Generate" is a somewhat ambiguous term, it enters a spreadsheet saves it with another extension, inserts a code and I want it to block the project.
– Leandro Felipe Moreira
Not really, because that would be changing, generating would be creating from scratch. Anyway the term is not what is under discussion and neither was the word you actually used. What I mean is, I can’t figure out where you’re opening the other rag, inserting code and changing the extension.
– Marco
Very careful with the way this is being done to another extension as the file may become invalid.
– Marco