forked from michaelneu/webxcel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.ps1
37 lines (31 loc) · 986 Bytes
/
export.ps1
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
. .\variables.ps1
. .\constants.ps1
. .\log.ps1
LogInfo "Collecting modules"
$missing = [System.Reflection.Missing]::Value
$excel = New-Object -ComObject Excel.Application
$book = $excel.Workbooks.Open($FILENAME, $missing, $true)
$modules = $book.VBProject.VBComponents;
$exportedModules = 0
For ($moduleIndex = 0; $moduleIndex -lt $modules.Count; $moduleIndex++)
{
$module = $modules.Item($moduleIndex + 1)
$moduleFilename = switch ($module.Type)
{
$COMPONENT_TYPE_MODULE { "src\Modules\$($module.Name).bas" }
$COMPONENT_TYPE_CLASS { "src\Classes\$($module.Name).cls" }
default { "" }
}
if ($moduleFilename -eq "")
{
echo "skipping module '$($module.Name)'"
continue
}
$moduleDestination = [IO.Path]::Combine($CWD, $moduleFilename)
echo "exporting $moduleFilename"
$module.Export($moduleDestination)
$exportedModules += 1
}
$excel.Quit()
LogInfo "Exported $exportedModules modules"
LogEmptyLine