Hello,
I try to schedule report with macro vba which filled automaticly prompt (begin and end dates)
and export the report in .txt file format which name contain the execution date .
The problem is that it work correctly in deski XI3.1 but when I tried to refresh the report within infoview, it dosen’t work properly.
First, the prompt does not filled in automaticly and the export files is not executed.
After, when I tried schedule without first part which is supposed to fill in audomaticly the prompt,
the exported run but the output file name doesn’t contain execution date.
The VBA’s code is here:
Dim BMname As String
Dim dtRun As String
Dim Outputdrive As String
Public Sub Document_BeforeRefresh(Cancel As Boolean)
'dtRun = Now()
dtRun = Format$(Now(), "yyyymmdd")
Outputdrive = "\\APSPRODBIXI\bixi@bca\NTAG\Daily\"
'Get report name
BMname = ThisDocument.Name
'create subdirectory
On Error Resume Next
MkDir Outputdrive
On Error GoTo 0
Rem Interactive = False
'Application.Interactive = False
Rem Create Date pour le Prompt et le rempli.
ThisDocument.Variables("Date2").Value = Format(Now(), "DD/MM/YYYY")
ThisDocument.Variables("Date2").Value = Weekday(ThisDocument.Variables("Date2").Value, vbMonday)
If ThisDocument.Variables("Date2").Value = 1 Then
ThisDocument.Variables("Date2").Value = Format(Now() - 3, "DD/MM/YYYY")
Else
ThisDocument.Variables("Date2").Value = Format(Now(), "DD/MM/YYYY")
End If
ThisDocument.Variables("Date1").Value = Format(Now() - 10, "DD/MM/YYYY")
ThisDocument.Variables("Date1").Value = Weekday(ThisDocument.Variables("Date1").Value, vbMonday)
If ThisDocument.Variables("Date1").Value = 7 Then
ThisDocument.Variables("Date1").Value = Format(Now() - 12, "DD/MM/YYYY")
Else
If ThisDocument.Variables("Date1").Value = 1 Then
ThisDocument.Variables("Date1").Value = Format(Now() - 10, "DD/MM/YYYY")
Else
If ThisDocument.Variables("Date1").Value = 6 Then
ThisDocument.Variables("Date1").Value = Format(Now() - 11, "DD/MM/YYYY")
Else
ThisDocument.Variables("Date1").Value = Format(Now() - 10, "DD/MM/YYYY")
End If
End If
End If
End Sub
Private Sub Document_AfterRefresh()
'BMname = ThisDocument.Name
'dtRun = Now()
'dtRun = Format$(Now(), "yyyymmdd")
'Outputdrive = "\\APSPRODBIXI\bixi@bca\NTAG\Daily\"
ThisDocument.SaveAs (Outputdrive & BMname & "_" & dtRun & ".txt")
'Application.Interactive = True
End Sub
Thank you for your help please… It’s urgent…
[Moderator Edit: Added code formatting - Andreas]
d_podjy (BOB member since 2010-05-12)