-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVBscript.vbs
86 lines (72 loc) · 2.38 KB
/
VBscript.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?
//Use PHP preprocessing to prepare variables
$xml_file=$working_directory . "session.xml";
include("template_xml.php");
$file_list = array();
foreach($measurements as $m)
{
if($m["Used"] === "True" and $m["Measurement_type"] === "Dynamic")
{
$path_parts = pathinfo($m["Filename"]);
$file_list[] = $path_parts['filename'];
}
}
?>
Option Explicit
ExcelMacroExample
Sub ExcelMacroExample()
Dim xlApp
Dim xlBook
Dim connection
Dim fileName
Dim fileList
'Start Excel and open template file
Set xlApp = CreateObject("Excel.Application")
xlApp.Application.Visible = True 'Set to False if Excel should not be visible.
Set xlBook = xlApp.Workbooks.Open("<?=$template_directory?>ExcelTemplate.xlsx", 0, True)
'Load tsv file
<?
echo('fileList=Array("' . implode('","', $file_list) . '")')
?>
For each fileName in fileList
connection = "TEXT;<?=$working_directory?>" + fileName + ".tsv"
'Import marker data from each QTM file into a separate worksheet
xlApp.Sheets(fileName).Select
With xlApp.ActiveSheet.QueryTables.Add(connection,xlApp.ActiveSheet.Range("$A$1"))
.Name = fileName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = 1
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = 1
.TextFileTextQualifier = 1
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "§"
.TextFileColumnDataTypes = Array(1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh False
End With
Next
xlApp.Sheets("Charts").Select
'Option to run additional macro that could contain more advanced processing steps. Excel template must be saved as .xlsm in that case:
'xlApp.Run "ExcelTemplate.xlsm!Module1.MyMacro"
xlApp.DisplayAlerts = False 'Set to False to hide Excel message when overwriting existing file.
xlBook.SaveAs("<?=$working_directory?>Report.xlsx")
'Uncomment this line to close Excel after running the macro:
'xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
End Sub