Answer the question
In order to leave comments, you need to log in
How to create a loop for archiving all xls in a folder, each into a separate file with a separate password?
Hi all! I tried to solve the problem with a bat script and it was successful, but there was a reason to read the contents of the xls cell and then batch fell ill :(
Please help me make a loop through all the xls files in a specific folder:
for each file:
-open, read the contents of the cell (for example R4C36) and write to variable1
- open a file with the name variable1 from the txt folder
- write the contents of txt (1 line to variable2,2 line to variable3)
-run the archiver where the password is variable2, the file name is variable3)
Answer the question
In order to leave comments, you need to log in
I thought about it, listened to the fact that there is nothing to store passwords separately and did the following on excel-vba
Dim sFolder
Dim Ofile
Sub Workbook_Open()
sFolder = "С:\01\xls\"
Set oFSO = CreateObject("Scripting.FileSystemObject")
For Each Ofile In oFSO.GetFolder(sFolder).Files
If UCase(oFSO.GetExtensionName(Ofile.Name)) = "XLS" Then
ProcessFiles oFSO, Ofile
End If
Next
Set oFSO = Nothing
End Sub
Sub ProcessFiles(FSO, File)
Dim excel
Workbooks.Open Filename:=Ofile
excel = ActiveCell.Cells(11, 1).Value
ActiveWorkbook.Close
Windows("start.xlsm").Activate
Sheets("Пароли").Select
a = Range("A1:B10").Find(excel).Row
b = Range("A1:B10").Find(excel).Column
pass = Sheets("Пароли").Cells(a, b + 1).Value
mail = Sheets("Пароли").Cells(a, b + 2).Value
FolderName = "С:\01\zip\"
PathZipProgram = "C:\Program Files\7-Zip\"
smail = FolderName + mail + ".zip"
ShellStr = PathZipProgram & "7z.exe a -tzip -p" & pass & "" & " " & smail & " " & Ofile & ""
Shell ShellStr
End Sub
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question