Eviews COM AUTOMATION ( EXCEL VBA)
Posted: Thu Feb 20, 2025 4:39 am
Hi all,
I’m working with a module in Excel VBA, and everything is running smoothly so far. However, I’ve encountered an issue when trying to implement Denton’s temporal disaggregation method. The code is not behaving as expected, and I’d appreciate your help in troubleshooting it.
Here's the code I'm working with:
Sub eviews_prova()
Dim mgr As New EViews.Manager
Dim app As EViews.Application
Dim wb As Workbook
Dim ws As Worksheet
Dim lastRow As Integer
Dim filePath As String
Dim destSheet As Worksheet
Dim eviewsFile As String
Dim seriesName As String
Dim command As String
Dim outputFilePath As String
filePath = "T:\Divisione Corporate\Dco Servizio Studi E Ricerche\Lavori\Banks-Market trends\ModelloPrevisioneSistemaBancario\Review 2024\Frequency_conversion\Sb2412v1.1.xlsx"
Set wb = Workbooks.Open(filePath)
Set ws = wb.Sheets("Tab_base") ' Foglio contenente i dati
lastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
ws.Range("C7:AUM" & lastRow).Copy
wb.Close False
Set app = mgr.GetApplication(ExistingOrNew)
app.Run "wfcreate q 1999 2032" ' Workfile trimestrale (cambia gli anni se serve)
app.Run "import " & Chr(34) & filePath & Chr(34) & " range=Tab_Base!C7:AUM" & lastRow & " colhead=1 @smpl 1981Q1 2032Q4"
seriesName = "LEV17"
' Temporal disagreggation with Denton
app.Run "series " & seriesName & "_m = @denton(" & seriesName & ", m, s)"
' Save date in an external CVS file
outputFilePath = "C:\Percorso\Del\Tuo\File_Mensilizzato.csv"
app.Run "wfsave(type=csv) " & outputFilePath
End Sub
I’ve highlighted in bold the command that is not working as expected. Specifically, I’m trying to apply Denton’s temporal disaggregation method, but it doesn't work correclty.
After resolving this issue, I plan to extend the code to import the monthly series from the CSV file.
Could anyone suggest what might be going wrong or help improve the code?
Thanks in advance for your help!
I’m working with a module in Excel VBA, and everything is running smoothly so far. However, I’ve encountered an issue when trying to implement Denton’s temporal disaggregation method. The code is not behaving as expected, and I’d appreciate your help in troubleshooting it.
Here's the code I'm working with:
Sub eviews_prova()
Dim mgr As New EViews.Manager
Dim app As EViews.Application
Dim wb As Workbook
Dim ws As Worksheet
Dim lastRow As Integer
Dim filePath As String
Dim destSheet As Worksheet
Dim eviewsFile As String
Dim seriesName As String
Dim command As String
Dim outputFilePath As String
filePath = "T:\Divisione Corporate\Dco Servizio Studi E Ricerche\Lavori\Banks-Market trends\ModelloPrevisioneSistemaBancario\Review 2024\Frequency_conversion\Sb2412v1.1.xlsx"
Set wb = Workbooks.Open(filePath)
Set ws = wb.Sheets("Tab_base") ' Foglio contenente i dati
lastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
ws.Range("C7:AUM" & lastRow).Copy
wb.Close False
Set app = mgr.GetApplication(ExistingOrNew)
app.Run "wfcreate q 1999 2032" ' Workfile trimestrale (cambia gli anni se serve)
app.Run "import " & Chr(34) & filePath & Chr(34) & " range=Tab_Base!C7:AUM" & lastRow & " colhead=1 @smpl 1981Q1 2032Q4"
seriesName = "LEV17"
' Temporal disagreggation with Denton
app.Run "series " & seriesName & "_m = @denton(" & seriesName & ", m, s)"
' Save date in an external CVS file
outputFilePath = "C:\Percorso\Del\Tuo\File_Mensilizzato.csv"
app.Run "wfsave(type=csv) " & outputFilePath
End Sub
I’ve highlighted in bold the command that is not working as expected. Specifically, I’m trying to apply Denton’s temporal disaggregation method, but it doesn't work correclty.
After resolving this issue, I plan to extend the code to import the monthly series from the CSV file.
Could anyone suggest what might be going wrong or help improve the code?
Thanks in advance for your help!