-
Notifications
You must be signed in to change notification settings - Fork 0
/
createSchemaFile.vbs
51 lines (39 loc) · 1.5 KB
/
createSchemaFile.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Option Explicit
' License GPL-3.0: https://choosealicense.com/licenses/gpl-3.0/
' Creating a file document through Zip container based on the scheme
Const VERSION = "0.01.000"
Dim fso, scriptFolder, zipFile, shell, schemaFiles
Set fso = CreateObject("Scripting.FileSystemObject")
scriptFolder = fso.GetAbsolutePathName(".")
Set shell = CreateObject("Shell.Application")
Set schemaFiles = shell.NameSpace(scriptFolder).ParseName("schema")
' Output file extension
Const EXTENTION = ".xlsx"
zipFile = scriptFolder & "\schemaOutput.zip"
With fso
If .FileExists(Replace(zipFile, ".zip", EXTENTION)) = True Then
' Clean up output File
.GetFile(Replace(zipFile, ".zip", EXTENTION)).Delete
WScript.Sleep 200
End If
If Not schemaFiles Is Nothing Then
Set schemaFiles = schemaFiles.GetFolder.Items
If schemaFiles.Count < 4 Then MsgBox "No schemaFiles found", 16: WScript.Quit
With .CreateTextFile(zipFile, True)
' Create an empty Zip container
.Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)
.Close
End With
' Copy schema folder to Zip container
shell.NameSpace(zipFile).CopyHere schemaFiles, 16
WScript.Sleep 500
If .GetFile(zipFile).Size < &H67C Then
MsgBox "Need the delay increased create to Zip container", 48
End If
' Rename the Zip container to change the file extension to the Extention
.GetFile(zipFile).Move Replace(zipFile, ".zip", EXTENTION)
End If
End With
Set schemaFiles = Nothing
Set shell = Nothing
Set fso = Nothing