Bloomberg or LSEG (London Stock Exchange Group, which has bought data business from Thomson-Reuters) provide subscribers with an add-in for Excel, which allows to dowload data into an Excel sheet. As I did not want to open and close many Excel-sheets manually, I looked for a way to automate that precudure of getting LSEG-data in a RATS program. Based on the topic https://www.estima.com/forum/viewtopic. ... 724#p19724 (winrats inter-operation), I thought that it could be done be various OS instructions. But somehow, the attempts failed.
Code: Select all
Calendar(M) 1992:01
comp start = 1992:01
comp ende = 2025:10
*
* compile the function string and write it in an Excel-sheet
comp macrostring = "=@RDP.HistoricalPricing(" + '"FRPPIY=ECIX"'+",VALUE,"+ $
'"START:31-Jan-1992 INTERVAL:P1M SOURCE:RFV"'+ ",,"+ $
'"SORT:ASC CH:Fd RH:Timestamp"'+",A1)"
* disp macrostring
report(action=define)
report(atrow=1,atcol=10) macrostring
open copy "S:\MyPath\RATS-Workstation Data.xlsx"
report(action=show,format=xlsx,unit=copy)
*
* Trying to run a batch file to start Excel and opening the file
*
OS "'Open Excel-Steet.bat'"
*
* Tryong to open Exel and loading the file
*
OS "C:\Program Files\Microsoft Office\root\Office16\excel.exe /d S:\MyPath'\RATS-Workstation Data.xlsx"
*
* Open with an vbs-script
*
OS "S:MyPath\Open Excel File.vbs"
*
* Close the Excel-File
OS "S:\'MyPath'\'Close Excel File'.vbs"
open data "S:\QCR Rats Files\RATS-Workstation Data.xlsx"
data(format=xlsx,org=col,labels) start ende FRPPIY<<ValueCode: Select all
echo off
start /d "C:\Program Files\Microsoft Office\root\Office16\" excel.exe "S:\MyPath\RATS-Workstation Data.xlsx"
pause
Code: Select all
Dim objExcel, objWB
dim i
dim WB_To_Close
set objExcel = GetObject(, "Excel.Application")
WB_To_Open = "RATS-Workstation Data.xlsx"
i = objExcel.Workbooks.Count
set objWB = objExcel.Workbooks(i+1)
if objWB.Name = WB_To_Close then
objWB.Open
end if
Code: Select all
Dim objExcel, objWB
dim i
dim WB_To_Close
set objExcel = GetObject(, "Excel.Application")
WB_To_Close = "RATS-Workstation Data.xlsx" ' enter name of WB to be closed here
for i = 1 to objExcel.Workbooks.Count
set objWB = objExcel.Workbooks(i)
if objWB.Name = WB_To_Close then
objWB.Save
objWB.Close
exit for
end if
i = i + 1
next
'if there are no more workbooks open in that instance of excel, then quit excel
if objExcel.Workbooks.Count = 0 then
objExcel.Quit
end ifWhat did I do wrong? It could save a lot of time if I can automate the process to download data and run the program file in batch mode during the night.
Best regards
PeterF