Sub ExtractMurexPositions()
Dim fs As FileSystemObject, PnlDate As Date, xmlFile As String, logFile As String, q As String
PnlDate = Date
xmlFile = "pos.xml" 'the script file
logFile = "pos.log" 'contains a string indicating if the script was terminated normally or abnormally
q = Chr(34)
Const MUREX_SCRIPT_NAME = "client_script.cmd"
Const MUREX_MACRO_DIR = "C:\Program Files\Murex"
Const UPLOAD_DIR = "c:\tmp"
Const mxPassword = "0090006000f0005600470"
Const mxID = "MUREX"
Const DynamicTable = "POSITIONS"
Const UserGroup = "TOKYO"
Set fs = New FileSystemObject
With fs.CreateTextFile(MUREX_MACRO_DIR & xmlFile, True)
.WriteLine "<?xml version=" & q & "1.0" & q & "?>"
.WriteLine "<!DOCTYPE MXClientScript>"
.WriteLine "<MXClientScript>"
.WriteLine " <Ignore>"
.WriteLine " <IgnoreDialog TextInDialog=" & q & q & " DefaultButton=" & q & "OK" & q & " />"
.WriteLine " <IgnoreDialog TextInDialog=" & q & "Confirm" & q & " DefaultButton=" & q & "Yes" & q & " />"
.WriteLine " <IgnoreDialog TextInDialog=" & q & "Quit" & q & " DefaultButton=" & q & "Yes" & q & " />"
.WriteLine " <IgnoreDialog TextInDialog=" & q & "Exit Program" & q & " DefaultButton=" & q & "Yes" & q & " />"
.WriteLine " </Ignore>"
.WriteLine " <Events>"
.WriteLine " <Modify EventID=" & q & "1" & q & ">"
.WriteLine " <Cell Type=" & q & "String" & q & ">" & mxID
.WriteLine " <Focus FocusCode=" & q & "_USR_LOG___USER_NAME___0" & q & " PanelFather=" & q & _
"OBJECT_2" & q & " Area=" & q & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q _
& "CaretPosition=" & q & Len(mxID) & q & "/>"
.WriteLine " </Cell>"
.WriteLine " <Cell Type=" & q & "String" & q & ">" & mxPassword
.WriteLine " <Focus FocusCode=" & q & "_USR_LOG___PASSWORD___0" & q & " PanelFather=" & q & _
"OBJECT_2" & q & " Area=" & q & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q _
& " CaretPosition=" & q & Len(mxPassword) & q & "/>"
.WriteLine " </Cell>"
.WriteLine " </Modify>"
.WriteLine " <Command Code=" & q & "AUTOMATIC_SAVE_AND_EXIT" & q & " EventID=" & q & "2" & q & ">"
.WriteLine " <Focus FocusCode=" & q & "_USR_LOG___PASSWORD___0" & q & " PanelFather=" & q & _
"OBJECT_2" & q & " Area=" & q & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q _
& "CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <Command Code=" & q & "AUTOMATIC_SELECT" & q & " EventID=" & q & "3" & q & ">"
.WriteLine " <Focus FocusCode=" & q & "Browse(3)" & q & " PanelFather=" & q & "OBJECT_3" & q & " Area=" _
& q & "TableBody" & q & " Line=" & q & "2" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q & _
" CaretPosition=" & q & "0" & q & " ScrollX=" & q & "0.0" & q & " XLine=" & q & "TSTO" & q & " XCol=" & q & _
"0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <Command Code=" & q & "COMMAND_100042" & q & " EventID=" & q & "4" & q & _
">Middle officeReportingDynamic tables configurationUser additional dynamic tables"
.WriteLine " <Focus FocusCode=" & q & "NO_FOCUS" & q & " PanelFather=" & q & "NO_FOCUS" & q & " _
Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q & _
" CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <ContextualMenu EventID=" & q & "5" & q & ">"
.WriteLine " <Focus FocusCode=" & q & "CmpMatrix__DBF_SEL1___Matrix___0" & q & " PanelFather=" & q _
& "OBJECT_9" & q & " Area=" & q & "TableBody" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q & _
" CaretPosition=" & q & "0" & q & " XLine=" & q & "TOR_POS" & q & " XCol=" & q & "0" & q & "/>"
.WriteLine " </ContextualMenu>"
.WriteLine " <Command Code=" & q & "COMMAND_2030" & q & " EventID=" & q & "6" & q & ">Test on screen"
.WriteLine " <Focus FocusCode=" & q & "CmpMatrix__DBF_SEL1___Matrix___0" & q & " PanelFather=" & _
q & "OBJECT_9" & q & " Area=" & q & "TableBody" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q & _
" CaretPosition=" & q & "0" & q & " XLine=" & q & "TOR_POS" & q & " XCol=" & q & "0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <Command Code=" & q & "COMMAND_1834" & q & " EventID=" & q & "7" & q & ">"
.WriteLine " <Focus FocusCode=" & q & "_DBF_SETSEL1___Proceed___0" & q & " PanelFather=" & q & _
"OBJECT_8" & q & " Area=" & q & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & _
q & " CaretPosition=" & q & "0" & q & "/>"
.WriteLine " <Focus FocusCode=" & q & "CmpMatrix__DBF_SETSEL1___Matrix___0" & q & " PanelFather=" & _
q & "OBJECT_8" & q & " Area=" & q & "TableBody" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q & _
" CaretPosition=" & q & "0" & q & " XLine=" & q & "<DEFAULT>" & q & " XCol=" & q & "0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <Modify EventID=" & q & "8" & q & ">"
.WriteLine " <Cell Type=" & q & "ComboBox" & q & ">Historical Date"
.WriteLine " <Focus FocusCode=" & q & "_DBF_SETTING2___DT_TYPE___2" & q & " PanelFather=" & q _
& "OBJECT_9" & q & " Area=" & q & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q & " CaretPosition=" & _
q & "0" & q & " XCol=" & q & "0" & q & "/>"
.WriteLine " </Cell>"
.WriteLine " </Modify>"
.WriteLine " <Modify EventID=" & q & "9" & q & ">"
.WriteLine " <Cell Type=" & q & "Date" & q & ">" & Format(PnlDate, "YYYYMMDD")
.WriteLine " <Focus FocusCode=" & q & "_DBF_SETTING2___DT_VALUE___2" & q & " PanelFather=" & _
q & "OBJECT_9" & q & " Area=" & q & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q & " CaretPosition=" _
& q & "0" & q & " XCol=" & q & "0" & q & "/>"
.WriteLine " </Cell>"
.WriteLine " </Modify>"
.WriteLine " <Command Code=" & q & "COMMAND_1996" & q & " EventID=" & q & "12" & q & ">"
.WriteLine " <Focus FocusCode=" & q & "_DBF_SETTING2___Save___0" & q & " PanelFather=" & q & _
"OBJECT_11" & q & " Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & _
"0" & q & " CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <Command Code=" & q & "COMMAND_1906" & q & " EventID=" & q & "13" & q & _
">ToolsView"
.WriteLine " <Focus FocusCode=" & q & "Browse(15)" & q & " PanelFather=" & q & "OBJECT_15" & q & _
" Area=" & q & "TableBody" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q & _
" CaretPosition=" & q & "0" & q & " ScrollX=" & q & "0.0" & q & " ScrollY=" & q & "0.0" & q & " XCol=" & q & _
"0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <Command Code=" & q & "AUTOMATIC_SELECT" & q & " EventID=" & q & "14" & q & ">"
.WriteLine " <Focus FocusCode=" & q & "Browse(16)" & q & " PanelFather=" & q & "OBJECT_16" & q & _
" Area=" & q & "TableBody" & q & " Line=" & q & "40" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q & _
" CaretPosition=" & q & "0" & q & " ScrollX=" & q & "0.0" & q & " XLine=" & q & "TOR_POS" & q & " XCol=" & _
q & "0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <Command Code=" & q & "COMMAND_1817" & q & " EventID=" & q & "15" & q & ">FileExtract"
.WriteLine " <Focus FocusCode=" & q & "Browse(15)" & q & " PanelFather=" & q & "OBJECT_15" & q & _
" Area=" & q & "TableBody" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q _
& " CaretPosition=" & q & "0" & q & " ScrollX=" & q & "0.0" & q & " ScrollY=" & q & "0.0" & q & " XCol=" & _
q & "0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <Modify EventID=" & q & "16" & q & ">"
.WriteLine " <Cell Type=" & q & "String" & q & ">a.txt"
.WriteLine " <Focus FocusCode=" & q & "_BRW_EXTRACT___FILE_NAME___0" & q & " PanelFather=" & _
q & "OBJECT_17" & q & " Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & _
q & "0" & q & " CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Cell>"
.WriteLine " <Cell Type=" & q & "ComboBox" & q & ">Overwrite"
.WriteLine " <Focus FocusCode=" & q & "_BRW_EXTRACT___OPEN_MODE___0" & q & " PanelFather=" & _
q & "OBJECT_17" & q & " Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & _
q & "0" & q & " CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Cell>"
.WriteLine " <Cell Type=" & q & "ComboBox" & q & ">Whole table"
.WriteLine " <Focus FocusCode=" & q & "_BRW_EXTRACT___SCOPE___0" & q & " PanelFather=" & q & _
"OBJECT_17" & q & " Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & _
"0" & q & " CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Cell>"
.WriteLine " <Cell Type=" & q & "ComboBox" & q & ">Yes"
.WriteLine " <Focus FocusCode=" & q & "_BRW_EXTRACT___TITLE___0" & q & " PanelFather=" & q & _
"OBJECT_17" & q & " Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & _
"0" & q & " CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Cell>"
.WriteLine " <Cell Type=" & q & "String" & q & ">"
.WriteLine " <Focus FocusCode=" & q & "_BRW_EXTRACT___STRING___0" & q & " PanelFather=" & q & _
"OBJECT_12" & q & " Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & _
"0" & q & " CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Cell>"
.WriteLine " <Cell Type=" & q & "String" & q & ">;"
.WriteLine " <Focus FocusCode=" & q & "_BRW_EXTRACT___COLUMN___0" & q & " PanelFather=" & q & _
"OBJECT_12" & q & " Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & _
"0" & q & " CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Cell>"
.WriteLine " <Cell Type=" & q & "String" & q & ">adhocftp.ksh TO a.txt pos_" & Format(PnlDate, "mmddyy") & _
".txt 1 1"
.WriteLine " <Focus FocusCode=" & q & "_BRW_EXTRACT___COMMAND___0" & q & " PanelFather=" & _
q & "OBJECT_17" & q & " Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q _
& "0" & q & " CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Cell>"
.WriteLine " <Cell Type=" & q & "ComboBox" & q & ">No"
.WriteLine " <Focus FocusCode=" & q & "_BRW_EXTRACT___FMT_NUM___0" & q & " PanelFather=" & q & _
"OBJECT_17" & q & " Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & _
"0" & q & " CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Cell>"
.WriteLine " </Modify>"
.WriteLine " <Command Code=" & q & "COMMAND_1834" & q & " EventID=" & q & "17" & q & ">"
.WriteLine " <Focus FocusCode=" & q & "_BRW_EXTRACT___BTN_PROCEED___0" & q & " PanelFather=" & _
q & "OBJECT_17" & q & " Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & _
"0" & q & " CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <Command Code=" & q & "AUTOMATIC_EXIT" & q & " EventID=" & q & "18" & q & ">"
.WriteLine " <Focus FocusCode=" & q & "Browse(10)" & q & " PanelFather=" & q & "OBJECT_15" & q & _
" Area=" & q & "TableBody" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q & _
" CaretPosition=" & q & "0" & q & " ScrollX=" & q & "0.0" & q & " ScrollY=" & q & "0.0" & q & " XCol=" & q & _
"0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <Dialog Aborted=" & q & "N" & q & " ReturnID=" & q & "0" & q & " EventID=" & q & "19" & q & ">"
.WriteLine " </Dialog>"
.WriteLine " <Command Code=" & q & "AUTOMATIC_EXIT" & q & " EventID=" & q & "20" & q & ">"
.WriteLine " <Focus FocusCode=" & q & "CmpMatrix__DBF_SEL1___Matrix___0" & q & " PanelFather=" & q _
& "OBJECT_9" & q & " Area=" & q & "TableBody" & q & " Line=" & q & "148" & q & " Col=" & q & "0" & q _
& " Ref=" & q & "0" & q & " CaretPosition=" & q & "0" & q & " ScrollX=" & q & "0.0" & q & " XCol=" & q & "0" & _
q & "/>"
.WriteLine " </Command>"
.WriteLine " <Command Code=" & q & "AUTOMATIC_EXIT" & q & " EventID=" & q & "21" & q & ">"
.WriteLine " <Focus FocusCode=" & q & "NO_FOCUS" & q & " PanelFather=" & q & "NO_FOCUS" & q & _
" Area=" & q & "" & q & " Line=" & q & "0" & q & " Col=" & q & "0" & q & " Ref=" & q & "0" & q & _
" CaretPosition=" & q & "0" & q & "/>"
.WriteLine " </Command>"
.WriteLine " <Dialog Aborted=" & q & "N" & q & " ReturnID=" & q & "0" & q & " EventID=" & q & "22" & q & ">"
.WriteLine " </Dialog>"
.WriteLine " </Events>"
.WriteLine "</MXClientScript>"
.Close
End With
sPath = CurDir
ChDrive Left(MUREX_MACRO_DIR, 1)
ChDir MUREX_MACRO_DIR
MXProgram = MUREX_SCRIPT_NAME & " /MXJ_SCRIPT_READ_FROM:" & xmlFile & _
" /MXJ_SCRIPT_LOG_FILE:" & UPLOAD_DIR & logFile
TaskId = Shell(MXProgram, vbNormalFocus)
Set fs = Nothing
On Error Resume Next
ChDrive Left(sPath, 1)
ChDir sPath
End Sub