Schedule DeskI to CSV

I have searched the forum and tried the code. I am getting error. I have limited vba knowledge. Can someone help me here. This is what I tried:


Sub MacroSalvaReport()
Dim bodoc As busobj.Document
Dim borep As busobj.Report

Dim nomefile As String
Dim inizioperiodo As String
Dim fineperiodo As String

Set bodoc = ActiveDocument
Set borep = bodoc.Reports(2)

'Parametro nel filtro 1. Inserire Data Inizio (gg/mm/aaaa)
inizioperiodo = Format(bodoc.Variables(1).Value, “yyyymmdd”)
'Parametro nel filtro 2. Inserire Data Fine (gg/mm/aaaa)
fineperiodo = Format(bodoc.Variables(2).Value, “yyyymmdd”)

nomefile = “C:” & inizioperiodo & “-” & fineperiodo & “.csv”

borep.ExportAsText (nomefile)

End Sub

Private Sub Document_AfterRefresh()
Call MacroSalvaReport
End Sub

I need to schedule a report everymonth and it should save it as CSV overwritting the existing csv file.

Any help is appreciated.

Thanks
Taurean


Taurean (BOB member since 2005-08-15)