Create folders from cell values

Keyboard macros or custom scripts

Create folders from cell values

Postby meha » Sun Aug 20, 2017 4:24 pm

I'd like to create folders from a list of cell values but I have no idea how.
Can anyone help?
OpenOffice 4.1.3 on Windows 10
meha
 
Posts: 1
Joined: Sun Aug 20, 2017 4:21 pm

Re: Create folders from cell values

Postby JohnSUN-Pensioner » Mon Aug 21, 2017 1:15 pm

Welcome to forum!
Which of the parts of this task be difficult - reading strings from the cells, or creating folders?
Code: Select all   Expand viewCollapse view
Sub crtFldrByCellVals
Dim oDataArray As Variant
Dim oData As Variant
Dim sBaseDir As String
Dim sTrgtDir As String
Dim i As Long
   GlobalScope.BasicLibraries.LoadLibrary("Tools")   
   sBaseDir = ThisComponent.getURL()
   If sBaseDir <> "" Then sBaseDir = DirectoryNameOutOfPath(sBaseDir, "/")
Rem Get data from selected cells
   oDataArray = ThisComponent.getCurrentSelection().getDataArray()
   For i = LBound(oDataArray) To UBound(oDataArray)
      oData = oDataArray(i)
Rem ... and create folder for each of them      
      sTrgtDir = ConvertToURL(sBaseDir & "/" & Trim(oData(0)))
      If Dir(sTrgtDir, 16)="" Then MkDir(sTrgtDir)
   Next i
End Sub
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.4, LibreOffice 5.4.2.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
JohnSUN-Pensioner
Volunteer
 
Posts: 758
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 2 guests